﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;
using System.Web.UI.WebControls;

namespace TestDxfDocument
{
    class IrregularInserts
    {
        public static void InsertOneCuttingEdgeForGroovingScrewMounting(Dictionary<string, Object> data)  //切槽切断刀片，单切削刃切槽，螺钉安装
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //参数
            
            double offset = 10;

            //double scale = 11; //放大系数
            double sbr = (Convert.ToDouble(data["insl"]) - Convert.ToDouble(data["pdy"])) * 2;
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && sbr < 29.7)
            {
                scale = 2.0;
            }
            else if (scale == 0 && sbr < 39.6)
            {
                scale = 1.5;
            }
            else if (scale == 0 && sbr < 59.4)
            {
                scale = 1.0;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }

            double pi = Math.PI;
            double isframe = Convert.ToDouble(data["isframe"]);
            double insl = Convert.ToDouble(data["insl"]) * scale;
            double s = Convert.ToDouble(data["s"]) * scale;
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            double d1 = Convert.ToDouble(data["d1"]) * scale;
            double w1 = Convert.ToDouble(data["w1"]) * scale;
            double rer = Convert.ToDouble(data["rer"]) * scale;
            double rel = Convert.ToDouble(data["rel"]) * scale;
            double rar = Convert.ToDouble(data["rar"]) * pi / 180;
            double ral = Convert.ToDouble(data["ral"]) * pi / 180;
            double pdy = Convert.ToDouble(data["pdy"]) * scale;
            double pdx = Convert.ToDouble(data["pdx"]) * scale;
            double pdpt = Convert.ToDouble(data["pdpt"]) * scale;
            double kchtl = Convert.ToDouble(data["kchtl"]) * pi / 180;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double an = Convert.ToDouble(data["an"]) * pi / 180;

            /*double an = 20 * pi / 180;
            double cw = 2 * scale;
            double kchtl = 45 * pi / 180;
            double pdpt = 3 * scale;
            double pdx = 8 * scale;
            double pdy = 15 * scale;
            double ral = 5 * pi / 180;
            double rar = 5 * pi / 180;
            double rel = 0.5 * scale;
            double rer = 0.5 * scale;
            double w1 = 10 * scale;
            double d1 = 5.16 * scale;
            double gan = 30 * pi / 180;
            double s = 4.76 * scale;
            double insl = 25 * scale;*/
            //double chwtl = pdy * 2 - insl - pdpt;
            double chwtl = pdy * 2 - insl - pdpt;
            double br = insl - pdy;
            double sr = (s * s - 2 * s * br + pdy * pdy) / 2 / (br + pdy * Math.Sin(gan) - (s - br) * Math.Cos(gan));
            double xr = s / 2 / Math.Cos(an * 2) / Math.Sin(an);
            //double isframe = 0;
            double x1 = 0;
            double x2 = 0;
            string path = Convert.ToString(data["path"]);

            //坐标
            //主视图
            Vector2 v1 = new Vector2(0, -insl + pdy);
            Vector2 v2 = new Vector2(0, -d1 / 2);
            Vector2 v3 = new Vector2(0, d1 / 2);
            Vector2 v4 = new Vector2(0, insl - pdy);
            Vector2 v10 = new Vector2(w1, -pdy);
            Vector2 v11 = new Vector2(v10.X - cw, v10.Y);
            Vector2 v12 = new Vector2(v11.X + pdpt * Math.Tan(ral), v11.Y + pdpt);
            Vector2 v13 = new Vector2(v12.X - chwtl / Math.Tan(kchtl), v1.Y);
            Vector2 v9 = new Vector2(v10.X - (pdpt + chwtl) * Math.Tan(rar), v13.Y);
            Vector2 v8 = new Vector2(v9.X - chwtl / Math.Tan(kchtl), v9.Y + chwtl);
            Vector2 v7 = new Vector2(v8.X, v2.Y);
            Vector2 v6 = new Vector2(v7.X, v3.Y);
            Vector2 v5 = new Vector2(v6.X, v4.Y);
            Vector2 v14 = new Vector2(-2, 0);
            Vector2 v15 = new Vector2(w1 + 2, 0);
            Vector2 v16 = new Vector2(v11.X + rel * Math.Tan(pi / 4 + ral / 2), v11.Y);
            Vector2 v17 = new Vector2(v16.X - rel * Math.Cos(ral), v11.Y + rel + rel * Math.Sin(ral));
            Vector2 v18 = new Vector2(v10.X - rer * Math.Tan(pi / 4 + rar / 2), v10.Y);
            Vector2 v19 = new Vector2(v18.X + rer * Math.Cos(rar), v10.Y + rer + rer * Math.Sin(rar));
            Vector2 v20 = new Vector2(v16.X, v16.Y + rel);
            Vector2 v21 = new Vector2(v18.X, v18.Y + rer);
            Vector2 v22 = new Vector2(v11.X, v11.Y - 5);
            Vector2 v23 = new Vector2(v11.X - 5 * Math.Sin(ral), v11.Y - 5 * Math.Cos(ral));
            Vector2 v24 = new Vector2(v10.X, v10.Y + pdpt);
            Vector2 v25 = new Vector2(v10.X + 59.4 + insl - pdy, v14.Y);
            Vector2 v26 = new Vector2(v10.X + 59.4, v25.Y);
            Vector2 v27 = new Vector2(v26.X, v10.Y + s * Math.Tan(an * 2));
            Vector2 v28 = new Vector2(v26.X + s, v10.Y);
            Vector2 v29 = new Vector2(2 * sr * Math.Cos(pi / 2 - 2 * an - gan) * Math.Cos(pi / 2 - 2 * an) + v28.X, 2 * sr * Math.Cos(pi / 2 - 2 * an - gan) * Math.Sin(pi / 2 - 2 * an) + v28.Y);
            Vector2 v30 = new Vector2(v26.X - 2, v26.Y);
            Vector2 v31 = new Vector2(v25.X + br + 2, v25.Y);
            Vector2 v32 = new Vector2(v25.X, v25.Y + br + 2);
            Vector2 v33 = new Vector2(v25.X, v25.Y - br - 2);
            Vector2 v34 = new Vector2(v26.X, v28.Y + s * Math.Tan(an));
            Vector2 v35 = new Vector2(v26.X, v28.Y);
            Vector2 v36 = new Vector2(v28.X, v28.Y - 5);
            Vector2 v37 = new Vector2(v28.X + 5 * Math.Tan(gan), v36.Y);
            Vector2 v42 = new Vector2(v28.X + xr * Math.Sin(an), v28.Y + xr * Math.Cos(an));//大圆心
            Vector2 v43 = new Vector2(v28.X + sr * Math.Cos(gan), v28.Y + sr * Math.Sin(gan));//小圆心
            if (v13.Y - v27.Y > 0)
            {
                x1 = v26.X;
            }
            else if (v13.Y - v27.Y < 0)
            {
                x1 = v42.X - Math.Sqrt(xr * xr - (v42.Y - v13.Y) * (v42.Y - v13.Y));
            }
            else
            {
                x1 = v27.X;
            }
            Vector2 v38 = new Vector2(x1, v13.Y); ;
            Vector2 v39 = new Vector2(v43.X - Math.Sqrt(sr * sr - (v13.Y - v43.Y) * (v13.Y - v43.Y)), v13.Y);
            if (v12.Y - v27.Y > 0)
            {
                x2 = v26.X;
            }
            else if (v12.Y - v27.Y < 0)
            {
                x2 = v42.X - Math.Sqrt(xr * xr - (v42.Y - v12.Y) * (v42.Y - v12.Y));
            }
            else
            {
                x2 = v27.X;
            }
            Vector2 v40 = new Vector2(x2, v12.Y);
            Vector2 v41 = new Vector2(v43.X - Math.Sqrt(sr * sr - (v12.Y - v43.Y) * (v12.Y - v43.Y)), v12.Y);

            //线段
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v19 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v18, v16 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v17, v12 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v13 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v13, v1 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v14, v15 };
            fun.drawPlinetype(dxf, Line14, 0.15, center, Linetype.Center);
            Vector2[] Line15 = { v3, v6 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v2, v7 };
            fun.drawBLine(dxf, Line16, 0.3, contour);

            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v16));
            Arc1.Vertexes.Add(new LwPolylineVertex(v17));
            Arc1.Vertexes[0].Bulge = -rel * (1 - Math.Cos(pi / 4 + ral / 2)) / (rel * Math.Sin(pi / 4 + ral / 2));
            fun.PolyFill(dxf, Arc1, 0.3, contour);

            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v19));
            Arc2.Vertexes.Add(new LwPolylineVertex(v18));
            Arc2.Vertexes[0].Bulge = -rer * (1 - Math.Cos(pi / 4 + rar / 2)) / (rer * Math.Sin(pi / 4 + rar / 2));
            fun.PolyFill(dxf, Arc2, 0.3, contour);

            Arc arc1 = fun.DrawArc(v17, v20, v16);
            Arc arc2 = fun.DrawArc(v18, v21, v19);

            Line Line17 = new Line(v11, v22);
            Line Line18 = new Line(v11, v23);
            Line Line19 = new Line(v10, v24);
            fun.drawcircle(dxf, v25, d1 / 2, 0.3, contour);
            fun.drawcircle(dxf, v25, br, 0.3, contour);
            Vector2[] Line20 = { v26, v27 };
            fun.drawBLine(dxf, Line20, 0.3, contour);

            LwPolyline Arc3 = new LwPolyline();
            Arc3.Vertexes.Add(new LwPolylineVertex(v28));
            Arc3.Vertexes.Add(new LwPolylineVertex(v27));
            Arc3.Vertexes[0].Bulge = -(1 - Math.Cos(an)) / Math.Sin(an);
            fun.PolyFill(dxf, Arc3, 0.3, contour);

            LwPolyline Arc4 = new LwPolyline();
            Arc4.Vertexes.Add(new LwPolylineVertex(v28));
            Arc4.Vertexes.Add(new LwPolylineVertex(v29));
            Arc4.Vertexes[0].Bulge = -sr * (1 - Math.Sin(pi / 2 - 2 * an - gan)) / (sr * Math.Cos(pi / 2 - 2 * an - gan));
            fun.PolyFill(dxf, Arc4, 0.3, contour);

            var circle1 = new Circle(v25, d1 / 2);
            Vector2[] Line21 = { v30, v31 };
            fun.drawPlinetype(dxf, Line21, 0.15, center, Linetype.Center);
            Vector2[] Line22 = { v32, v33 };
            fun.drawPlinetype(dxf, Line22, 0.15, center, Linetype.Center);
            Line Line23 = new Line(v28, v34);
            Line Line24 = new Line(v28, v35);
            Line Line25 = new Line(v28, v36);
            Line Line26 = new Line(v28, v37);
            Vector2[] Line27 = { v38, v39 };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            Vector2[] Line28 = { v40, v41 };
            fun.drawBLine(dxf, Line28, 0.3, contour);

            //图层
            Line17.Layer = dimensioning;
            Line17.Linetype = Linetype.Continuous;
            dxf.AddEntity(Line17);
            Line18.Layer = dimensioning;
            Line18.Linetype = Linetype.Continuous;
            dxf.AddEntity(Line18);
            Line19.Layer = dimensioning;
            Line19.Linetype = Linetype.Continuous;
            dxf.AddEntity(Line19);
            Line23.Layer = dimensioning;
            Line23.Linetype = Linetype.Continuous;
            dxf.AddEntity(Line23);
            Line24.Layer = dimensioning;
            Line24.Linetype = Linetype.Continuous;
            dxf.AddEntity(Line24);
            Line25.Layer = dimensioning;
            Line25.Linetype = Linetype.Continuous;
            dxf.AddEntity(Line25);
            Line26.Layer = dimensioning;
            Line26.Linetype = Linetype.Continuous;
            dxf.AddEntity(Line26);

            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v11));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v12));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
                if (htype1[i] == "Arc")
                {
                    harc1[i] = (Arc)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 5, hline1, harc1, hatching);

            LwPolyline hatchpoly2 = new LwPolyline();
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly2.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly2.IsClosed = true;
            String[] htype2 = new String[100];
            Line[] hline2 = new Line[100];
            Arc[] harc2 = new Arc[100];
            int hnumst2 = hatchpoly2.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst2; i++)
            {
                htype2[i] = hatchpoly2.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype2[i] == "Line")
                {
                    hline2[i] = (Line)hatchpoly2.Explode()[i];
                }
                if (htype2[i] == "Arc")
                {
                    harc2[i] = (Arc)hatchpoly2.Explode()[i];
                }
            }
            fun.hatchsub1(dxf, htype2, hnumst2, 45, 5, hline2, harc2, hatching);

            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.DimStyle(true);
            DimensionStyle dimensionStyle2= fun.DimStyle(false);


            double height = 3.5;
            double arrowsize = height;
            double exline = height/2;

            //线段尺寸标注
            //尺寸1
            /*Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v1, v43), new Line(v1, v44), offset, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);*/

            /*LinearDimension dim1 = new LinearDimension(new Line(v11, v12), -offset - pdx - (v12.X - v11.X), 270, dimensionStyle);
            dim1.UserText = "PDPT = " + Math.Round(pdpt / scale, 2);
            dxf.AddEntity(dim1);*/
            fun.dimrot1(dxf, v11, v12, 90, offset + pdx + (v12.X - v11.X)/2, 1, height, arrowsize, exline, "PDPT" /*+ Math.Round(pdpt / scale, 2)*/, "", "");

            //尺寸2
            /*LinearDimension dim2 = new LinearDimension(new Line(v11, new Vector2(0, 0)), -offset * 2 - pdx / 2, 270, dimensionStyle);
            dim2.UserText = "PDY = " + Math.Round(pdy / scale, 2);
            dxf.AddEntity(dim2);*/
            fun.dimrot1(dxf, v11, new Vector2(0, 0), 90, offset * 2 + pdx / 2, 1, height, arrowsize, exline, "PDY" /*+ Math.Round(pdy / scale, 2)*/, "", "");

            //尺寸3
            /*LinearDimension dim3 = new LinearDimension(new Line(v11, v4), -offset * 3 - pdx / 2, 270, dimensionStyle);
            dim3.UserText = "INSL = " + Math.Round(insl / scale, 2);
            dxf.AddEntity(dim3);*/
            fun.dimrot1(dxf, v11, v4, 90, offset * 3 + pdx / 2, 1, height, arrowsize, exline, "INSL" /*+ Math.Round(insl / scale, 2)*/, "", "");

            //尺寸4
            /*LinearDimension dim4 = new LinearDimension(new Line(v4, v10), offset + (v4.Y - v10.Y) / 2, 0, dimensionStyle);
            dim4.UserText = "W1 = " + Math.Round(w1 / scale, 2);
            dxf.AddEntity(dim4);*/
            fun.dimrot1(dxf, v4, v10, 180, offset*3 + (v4.Y - v10.Y) / 2, 1, height, arrowsize, exline, "W1" /*+ Math.Round(w1 / scale, 2)*/, "", "");

            //尺寸5
            RadialDimension dimrad1 = new RadialDimension(arc1, -135 - ral / 2 * 180 / pi, 1, dimensionStyle);
            dimrad1.UserText = "REL" /*+ Math.Round(rel / scale, 2)*/;
            dxf.AddEntity(dimrad1);


            //尺寸6
            RadialDimension dimrad2 = new RadialDimension(arc2, -45 - rar / 2 * 180 / pi, offset, dimensionStyle);
            dimrad2.UserText = "RER" /*+ Math.Round(rer / scale, 2)*/;
            
            dxf.AddEntity(dimrad2);

            //尺寸7

            //Angular2LineDimension angdim1 = new Angular2LineDimension(Line17, Line18, offset , dimensionStyle);
            Angular3PointDimension angdim1 = new Angular3PointDimension(v11, v23, new Vector2(v11.X, v11.Y - 1), offset  , dimensionStyle2);
            angdim1.UserText = "RAL" /*+ Math.Round(ral / (pi / 180), 2) + "°"*/;
            dxf.AddEntity(angdim1);

            //尺寸8
            //Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(v10, v9), Line19, offset, dimensionStyle);
            Angular3PointDimension angdim2 = new Angular3PointDimension(v10,new Vector2(v10.X,v10.Y+1),v9, offset*2, dimensionStyle2);
            angdim2.UserText = "RAR" /*+ Math.Round(rar / (pi / 180), 2) + "°"*/;
            dxf.AddEntity(angdim2);


            //尺寸9
            /*LinearDimension dim9 = new LinearDimension(new Line(v1, v11), -2.5 * offset - (v1.Y - v11.Y) / 2 * 3, 0, dimensionStyle);
            dim9.UserText = "PDX = " + Math.Round(pdx / scale, 2);
            dxf.AddEntity(dim9);*/
            fun.dimrot1(dxf, v1, v11, 180, offset*2 +Math.Abs (v1.Y-v11.Y)/2, 1, height, arrowsize, exline, "PDX" /*+ Math.Round(pdx / scale, 2)*/, "", "");

            //尺寸10
            /*LinearDimension dim10 = new LinearDimension(new Line(v11, v10), -2.5 * offset - 2 * dimensionStyle.TextHeight * 3, 0, dimensionStyle);
            dim10.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim10);*/
            fun.dimrot1(dxf, v11, v10, 180, offset*2 , 1, height, arrowsize, exline, "CW" /*+ Math.Round(cw / scale, 2)*/, "", "");

            //尺寸11
            var dim11 = new DiametricDimension(circle1, 45, br + offset, dimensionStyle);
            dim11.UserText = "D1" /*+ Math.Round(d1 / scale, 2)*/;
            dxf.AddEntity(dim11);

            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v27, v28), -offset - (v27.Y - v28.Y) / 2, 0, dimensionStyle);
            dim12.UserText = "S" /*+ Math.Round(s / scale, 2)*/;
            dxf.AddEntity(dim12);

            //尺寸13
            Angular2LineDimension dim13 = new Angular2LineDimension(new Line(v28, v34), new Line(v28, v35), offset *3, dimensionStyle);
            dim13.UserText = "AN" /*+ Math.Round(an / (pi / 180), 2) + "°"*/;
            dxf.AddEntity(dim13);

            //尺寸14
            Angular2LineDimension dim14 = new Angular2LineDimension(Line25, Line26, offset*2, dimensionStyle);
            dim14.UserText = "GAN" /*+ Math.Round(gan / (pi / 180), 2) + "°"*/;
            dxf.AddEntity(dim14);

            //坐标系
            fun.Axis(dxf, new Vector2(0, 0), 180, 270, "MCS,PCS", "", "", 0.3, height, 1);
            fun.Axis(dxf, new Vector2(v1.X - w1, v1.Y - pdpt * 3), 180, 270, "Z", "X", "Y", 0.3, height, 1);//XYZ
            fun.Axis(dxf, v25, 0, 270, "MSC,PCS", "", "", 0.3, height, 1);

            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2((v10.X + v26.X) / 2 - 148.5, v26.Y + 105), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void InsertOneCuttingEdgeForGroovingAndPartingSelfClamping(Dictionary<string, Object> data)  //刀片，单切削刃切槽和切断，自-夹紧
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //参数
            double sl = Convert.ToDouble(data["insl"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && sl < 37.5)
            {
                scale = 2.0;
            }
            else if (scale == 0 && sl < 50)
            {
                scale = 1.5;
            }
            else if (scale == 0 && sl < 75)
            {
                scale = 1.0;
            }
            else if (scale == 0 && sl < 100)
            {
                scale = 0.75;
            }
            else if (scale == 0 && sl < 150)
            {
                scale = 0.5;
            }
            else if (scale == 0)
            {
                scale = 0.25;
            }
            double pi = Math.PI;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double s = Convert.ToDouble(data["s"]) * scale;
            double s1 = Convert.ToDouble(data["s1"]) * scale;
            if (s1 == 0)
            {
                s1 = s + 3;
            }
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            double insl = Convert.ToDouble(data["insl"]) * scale;
            double bw = Convert.ToDouble(data["bw"]) * scale;
            double pdpt = Convert.ToDouble(data["pdpt"]) * scale;
            double rel = Convert.ToDouble(data["rel"]) * scale;
            double rer = Convert.ToDouble(data["rer"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            double a = 1 - Math.Pow(Math.Tan(gan), 2) * Math.Pow(Math.Tan(an), 4) + 2 * Math.Pow(Math.Tan(an), 3) * Math.Tan(gan);
            double b = -2 * s1 - 2 * pdpt * Math.Tan(an) - 2 * s1 * Math.Pow(Math.Tan(an), 2) + 2 * s * Math.Pow(Math.Tan(gan), 2) * Math.Pow(Math.Tan(an), 4) + 2 * pdpt * Math.Pow(Math.Tan(an), 3) * Math.Pow(Math.Tan(gan), 2) + 2 * s * Math.Pow(Math.Tan(an), 2) - 2 * pdpt * Math.Tan(gan) * Math.Pow(Math.Tan(an), 2) - 4 * s * Math.Pow(Math.Tan(an), 3) * Math.Tan(gan);
            double c = Math.Pow(s1, 2) + Math.Pow(pdpt, 2) * Math.Pow(Math.Tan(an), 2) + 2 * pdpt * s1 * Math.Tan(an) + Math.Pow(s1, 2) * Math.Pow(Math.Tan(an), 2) - Math.Pow(pdpt, 2) * Math.Pow(Math.Tan(an), 2) * Math.Pow(Math.Tan(gan), 2) - Math.Pow(s, 2) * Math.Pow(Math.Tan(an), 4) * Math.Pow(Math.Tan(gan), 2) - 2 * pdpt * s * Math.Pow(Math.Tan(an), 3) * Math.Pow(Math.Tan(gan), 2) - Math.Pow(s, 2) * Math.Pow(Math.Tan(an), 2) + 2 * s * pdpt * Math.Tan(gan) * Math.Pow(Math.Tan(an), 2) + 2 * Math.Pow(s, 2) * Math.Pow(Math.Tan(an), 3) * Math.Tan(gan);
            double x = (-b + Math.Sqrt(b * b - 4 * a * c)) / 2 / a;
            double r = Math.Sqrt(Math.Pow((x - s1) / Math.Tan(an) - pdpt, 2) + Math.Pow(x - s1, 2));
            //坐标
            //主视图
            Vector2 v1 = new Vector2(x - s, (x - s) * Math.Tan(an));
            Vector2 v2 = new Vector2(x, x * Math.Tan(an));
            Vector2 v3 = new Vector2((insl - v2.Y) * Math.Tan(an) + x, insl);
            Vector2 v4 = new Vector2(insl * Math.Tan(an), insl);
            Vector2 v5 = new Vector2(x - s1, (x - s1) / Math.Tan(an));
            Vector2 v6 = new Vector2(r, pdpt);
            Vector2 v7 = new Vector2(r * (v5.Y - v6.Y) / Math.Sqrt(Math.Pow(v5.Y - v6.Y, 2) + Math.Pow(v6.X - v5.X, 2)), v6.Y + r * (v6.X - v5.X) / Math.Sqrt(Math.Pow(v5.Y - v6.Y, 2) + Math.Pow(v6.X - v5.X, 2)));
            Vector2 v11 = new Vector2(v1.X + s / 2, s / 2 * Math.Tan(an) + v1.Y);
            Vector2 v8 = new Vector2(v11.X, v7.Y);
            Vector2 v10 = new Vector2(rer / Math.Cos(an + gan) * Math.Sin(gan) + v1.X, rer / Math.Cos(an + gan) * Math.Cos(gan) + v1.Y);
            Vector2 v9 = new Vector2(v11.X, v11.Y + rer / Math.Cos(an));
            Vector2 v12 = new Vector2((v3.X + v4.X + v2.X) / 4 + 170 - bw / 2, v3.Y);
            Vector2 v13 = new Vector2(v12.X + bw, v3.Y);
            Vector2 v14 = new Vector2(v13.X, v8.Y);
            Vector2 v15 = new Vector2((v3.X + v4.X + v2.X) / 4 + 170 + cw / 2, v14.Y);
            Vector2 v16 = new Vector2(v15.X, v10.Y);
            Vector2 v17 = new Vector2(v16.X - rer, v1.Y);
            Vector2 v18 = new Vector2((v3.X + v4.X + v2.X) / 4 + 170 - cw / 2 + rel, v17.Y);
            Vector2 v19 = new Vector2(v18.X - rel, rel / Math.Cos(an + gan) * Math.Cos(gan) + v1.Y);
            Vector2 v20 = new Vector2(v19.X, v15.Y);
            Vector2 v21 = new Vector2(v12.X, v20.Y);
            Vector2 v22 = new Vector2(v20.X, v6.Y);
            Vector2 v23 = new Vector2(v15.X, v22.Y);
            Vector2 v24 = new Vector2(v12.X, v5.Y);
            Vector2 v25 = new Vector2(v13.X, v24.Y);
            Vector2 v26 = new Vector2((v12.X + v13.X) / 2, (v20.Y + v22.Y) / 2);
            double a1 = (v24.Y - v26.Y) / Math.Pow(v26.X - v24.X, 2);
            double b1 = -2 * a1 * v26.X;
            double c1 = v24.Y - a1 * Math.Pow(v24.X, 2) - b1 * v24.X;
            Vector2 v27 = new Vector2(v26.X - bw / 3, a1 * (v26.X - bw / 3) * (v26.X - bw / 3) + b1 * (v26.X - bw / 3) + c1);
            Vector2 v28 = new Vector2(v26.X + bw / 3, v27.Y);
            Vector2 v29 = new Vector2((v12.X + v13.X) / 2, v12.Y + 2);
            Vector2 v30 = new Vector2(v29.X, v18.Y - 2);
            Vector2 v31 = new Vector2(v2.X, v1.Y);
            Vector2 v32 = new Vector2(v1.X, v1.Y - 5);
            Vector2 v33 = new Vector2(v1.X - 5 * Math.Tan(gan), v32.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v5));
            Arc1.Vertexes.Add(new LwPolylineVertex(v6));
            Arc1.Vertexes[0].Bulge = -r * (1 - (v5.Y - v6.Y) / Math.Sqrt(Math.Pow(v5.Y - v6.Y, 2) + Math.Pow(v6.X - v5.X, 2))) / (r * (v6.X - v5.X) / Math.Sqrt(Math.Pow(v5.Y - v6.Y, 2) + Math.Pow(v6.X - v5.X, 2)));
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            Vector2[] Line5 = { v6, v1 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v7, v8 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v8, v11 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v9, v10 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            //左视图
            Vector2[] Line9 = { v12, v13 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v13, v14 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v14, v15 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v15, v16 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v16));
            Arc2.Vertexes.Add(new LwPolylineVertex(v17));
            Arc2.Vertexes[0].Bulge = -(1 - Math.Cos(45 * pi / 180)) / Math.Sin(45 * pi / 180);
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            Vector2[] Line13 = { v17, v18 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            LwPolyline Arc3 = new LwPolyline();
            Arc3.Vertexes.Add(new LwPolylineVertex(v18));
            Arc3.Vertexes.Add(new LwPolylineVertex(v19));
            Arc3.Vertexes[0].Bulge = -(1 - Math.Cos(45 * pi / 180)) / Math.Sin(45 * pi / 180);
            fun.PolyFill(dxf, Arc3, 0.3, contour);
            Vector2[] Line14 = { v19, v20 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v20, v21 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v21, v12 };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v22, v23 };
            fun.drawBLine(dxf, Line17, 0.3, contour);
            Vector2[] Line18 = { v24, v27 };
            fun.drawBLine(dxf, Line18, 0.3, contour);
            Vector2[] Line19 = { v27, v26 };
            fun.drawBLine(dxf, Line19, 0.3, contour);
            Vector2[] Line20 = { v26, v28 };
            fun.drawBLine(dxf, Line20, 0.3, contour);
            Vector2[] Line21 = { v28, v25 };
            fun.drawBLine(dxf, Line21, 0.3, contour);
            Vector2[] Line22 = { v29, v30 };
            fun.drawPlinetype(dxf, Line22, 0.15, center, Linetype.Center);
            Vector2[] Line23 = { v1, v31 };
            fun.drawPlinetype(dxf, Line23, 0.15, dimensioning, Linetype.Continuous);
            Vector2[] Line24 = { v1, v32 };
            fun.drawPlinetype(dxf, Line24, 0.15, dimensioning, Linetype.Continuous);
            Vector2[] Line25 = { v1, v33 };
            fun.drawPlinetype(dxf, Line25, 0.15, dimensioning, Linetype.Continuous);
            Vector2[] Line26 = { v27, new Vector2(v27.X, v12.Y) };
            fun.drawBLine(dxf, Line26, 0.3, contour);
            Vector2[] Line27 = { v28, new Vector2(v28.X, v12.Y) };
            fun.drawBLine(dxf, Line27, 0.3, contour);
            Arc arc1 = fun.DrawArc(v19, new Vector2(v18.X, v19.Y), v18);
            Arc arc2 = fun.DrawArc(v17, new Vector2(v17.X, v16.Y), v16);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0 / 2;
            double offset = 5;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v1, v31), new Line(v1, v2), s + offset, dimensionStyle);
            angdim1.UserText = "AN = " + Math.Round(an / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸2
            Angular2LineDimension angdim2 = new Angular2LineDimension(new Line(v1, v33), new Line(v1, v32), offset * 2, dimensionStyle);
            angdim2.UserText = "GAN = " + Math.Round(gan / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v1, v2), -offset - (v1.Y + v2.Y) / 2, 0, dimensionStyle);
            dim3.UserText = "S = " + Math.Round(s / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v12, v13), offset, 0, dimensionStyle);
            dim4.UserText = "BW = " + Math.Round(bw / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            RadialDimension dimrad1 = new RadialDimension(arc1, -135, 5, dimensionStyle);
            dimrad1.UserText = "REL = " + Math.Round(rel / scale, 2);
            dxf.AddEntity(dimrad1);
            //尺寸6
            RadialDimension dimrad2 = new RadialDimension(arc2, -45, 5, dimensionStyle);
            dimrad2.UserText = "RER = " + Math.Round(rer / scale, 2);
            dxf.AddEntity(dimrad2);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v19, v16), -offset - (rel + rer) / 2, 0, dimensionStyle);
            dim7.UserText = "CW = " + Math.Round(cw / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v12, v18), -offset - (v12.X - v19.X) / 2, 270, dimensionStyle);
            dim8.UserText = "INSL = " + Math.Round(insl / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v23, v17), offset + rer, 270, dimensionStyle);
            dim9.UserText = "PDPT = " + Math.Round(pdpt / scale, 2);
            dxf.AddEntity(dim9);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2((v3.X + v4.X + v2.X) / 4 - 62.5, (v12.Y + v18.Y) / 2 + 105), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void InsertTwoCuttingEdgesForGroovingAndPartingSelfClamping(Dictionary<string, Object> data)  //刀片，双切削刃的切槽和切断，自-夹紧
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double offset = 10;
            double textsize = 3.5;

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            /*
            double insl = 100;// Convert.ToDouble(data["insl"]);
            double bw = 20;// Convert.ToDouble(data["bw"]);
            double pdpt = 20;// Convert.ToDouble(data["pdpt"]);
            double rel = 1;// Convert.ToDouble(data["rel"]);
            double rer = 1;// Convert.ToDouble(data["rer"]);
            double cw = 25;// Convert.ToDouble(data["cw"]);
            double s1 = 45;// Convert.ToDouble(data["s1"]);
            double s = 42;// Convert.ToDouble(data["s"]);
            double an = 10 * pi / 180;// Convert.ToDouble(data["an"]) * pi / 180;
            double gan = 5 * pi / 180;// Convert.ToDouble(data["gan"]) * pi / 180;
            */
            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);

            double scale = Convert.ToDouble(data["scale"]); //放大系数
            try
            {
                scale = Convert.ToDouble(data["scale"]);
            }
            catch (Exception e)
            {
                Console.WriteLine("[scale] not found");
            }
            var insl = Convert.ToDouble(data["insl"]) * scale;//= 23.8;

            var cw = Convert.ToDouble(data["cw"]) * scale; //2;
            var re = Convert.ToDouble(data["rel"]) * scale; //0.2;
            var rel = Convert.ToDouble(data["rel"]) * scale;
            if (rel == 0)
            {
                rel = re;
            }
            var rer = Convert.ToDouble(data["rer"]) * scale;
            if (rer == 0)
            {
                rer = re;
            }
            var bw = Convert.ToDouble(data["bw"]);
            if (bw == 0)
            {
                bw = 20.0 / 25 * cw;
            }
            var pdpt = Convert.ToDouble(data["pdpt"]) * scale;
            if (pdpt == 0)
            {
                pdpt = 20 / 100.0 * insl;
            }
            var s1 = Convert.ToDouble(data["s1"]) * scale;
            if (s1 == 0)
            {
                s1 = 45.0 / 100 * insl;
            }
            var s = Convert.ToDouble(data["s"]) * scale;
            if (s == 0)
            {
                s = 42 / 100.0 * insl;
            }
            var an = Convert.ToDouble(data["an"]) * pi / 180;
            if (an == 0)
            {
                an = 10 * pi / 180;
            }
            var gan = Convert.ToDouble(data["gan"]) * pi / 180;
            if (gan == 0)
            {
                gan = 5 * pi / 180;
            }




            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = new Vector2(p0.X - 0.45 * bw, p0.Y + 0.15 * insl);
            Vector2 p2 = fun.Polar(p1, 0, 0.9 * bw);
            Vector2 p3 = fun.Polar(p2, 1.5 * pi, 0.3 * insl);
            Vector2 p4 = new Vector2(p1.X, p3.Y);
            Vector2 p5 = new Vector2(p0.X - cw / 2, p0.Y + insl / 2);
            Vector2 p6 = fun.Polar(p5, 0, rer);
            Vector2 p7 = fun.Polar(p5, 0, cw - rel);
            Vector2 p8 = fun.Polar(p5, 0, cw);
            Vector2 p9 = fun.Polar(p8, 1.5 * pi, rel);
            Vector2 p10 = fun.Polar(p8, 1.5 * pi, pdpt);
            Vector2 p11 = fun.Polar(p10, 1.5 * pi, 0.1 * insl);
            Vector2 p12 = new Vector2(p0.X + bw / 2, p11.Y - 0.03 * insl);
            Vector2 p25 = new Vector2(p0.X - p12.X, p12.Y);
            Vector2 p26 = new Vector2(p0.X - p11.X, p11.Y);
            Vector2 p27 = new Vector2(p0.X - p10.X, p10.Y);
            Vector2 p28 = new Vector2(p0.X - p9.X, p9.Y);
            Vector2 p13 = new Vector2(p12.X, p0.Y - p12.Y);
            Vector2 p14 = new Vector2(p11.X, p0.Y - p11.Y);
            Vector2 p15 = new Vector2(p10.X, p0.Y - p10.Y);
            Vector2 p16 = new Vector2(p9.X, p0.Y - p9.Y);
            Vector2 p17 = new Vector2(p8.X, p0.Y - p8.Y);
            Vector2 p18 = new Vector2(p7.X, p0.Y - p7.Y);
            Vector2 p19 = new Vector2(p6.X, p0.Y - p6.Y);
            Vector2 p20 = new Vector2(p5.X, p0.Y - p5.Y);
            Vector2 p21 = new Vector2(p28.X, p0.Y - p28.Y);
            Vector2 p22 = new Vector2(p27.X, p0.Y - p27.Y);
            Vector2 p23 = new Vector2(p26.X, p0.Y - p26.Y);
            Vector2 p24 = new Vector2(p25.X, p0.Y - p25.Y);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes[1].Bulge = Math.Tan(pi / 16);
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes[3].Bulge = Math.Tan(pi / 16);
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            fun.PolyFill(dxf, poly1, 0.3, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p6));
            poly2.Vertexes[0].Bulge = Math.Tan(pi / 8);
            poly2.Vertexes.Add(new LwPolylineVertex(p28));
            poly2.Vertexes.Add(new LwPolylineVertex(p26));
            poly2.Vertexes.Add(new LwPolylineVertex(p25));
            poly2.Vertexes.Add(new LwPolylineVertex(p24));
            poly2.Vertexes.Add(new LwPolylineVertex(p23));
            poly2.Vertexes.Add(new LwPolylineVertex(p22));
            poly2.Vertexes.Add(new LwPolylineVertex(p21));
            poly2.Vertexes[7].Bulge = Math.Tan(pi / 8);
            poly2.Vertexes.Add(new LwPolylineVertex(p19));
            poly2.Vertexes.Add(new LwPolylineVertex(p18));
            poly2.Vertexes[9].Bulge = Math.Tan(pi / 8);
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes.Add(new LwPolylineVertex(p14));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes[15].Bulge = Math.Tan(pi / 8);
            poly2.Vertexes.Add(new LwPolylineVertex(p7));
            poly2.Vertexes.Add(new LwPolylineVertex(p6));
            fun.PolyFill(dxf, poly2, 0.3, contour);

            Vector2[] line1 = { p10, p27 };
            fun.drawBLine(dxf, line1, 0.3, contour);
            Vector2[] line2 = { p15, p22 };
            fun.drawBLine(dxf, line2, 0.3, contour);

            Vector2 p0p = fun.Polar(p0, 0, insl);
            Vector2 p40 = new Vector2(p0p.X, p8.Y - pdpt / 2);
            Vector2 p41 = new Vector2(p0p.X + s, p8.Y);
            Vector2 p41p = fun.Polar(p41, pi + an, 0.5);
            Vector2 p43 = new Vector2(p0p.X + s1, p1.Y);
            Vector2 p44 = new Vector2(p0p.X + s1, p4.Y);
            Vector2 p46 = new Vector2(p41.X, p17.Y);
            Vector2 p46p = fun.Polar(p46, pi - an, 0.5);
            Vector2 p47 = new Vector2(p0p.X, p17.Y + pdpt / 2);
            Vector2 p42 = fun.Polar(p41, 1.5 * pi - gan, pdpt / Math.Cos(gan));
            Vector2 p45 = fun.Polar(p46, 0.5 * pi + gan, pdpt / Math.Cos(gan));

            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p40));
            poly3.Vertexes.Add(new LwPolylineVertex(p41p));
            poly3.Vertexes.Add(new LwPolylineVertex(p41));
            poly3.Vertexes.Add(new LwPolylineVertex(p42));
            poly3.Vertexes[3].Bulge = Math.Tan(pi / 10);
            poly3.Vertexes.Add(new LwPolylineVertex(p43));
            poly3.Vertexes.Add(new LwPolylineVertex(p44));
            poly3.Vertexes[5].Bulge = Math.Tan(pi / 10);
            poly3.Vertexes.Add(new LwPolylineVertex(p45));
            poly3.Vertexes.Add(new LwPolylineVertex(p46));
            poly3.Vertexes.Add(new LwPolylineVertex(p46p));
            poly3.Vertexes.Add(new LwPolylineVertex(p47));
            poly3.Vertexes.Add(new LwPolylineVertex(p40));
            fun.PolyFill(dxf, poly3, 0.3, contour);

            Vector2 p60 = new Vector2(p0p.X, p12.Y);
            Vector2 p61 = new Vector2(p60.X + s / 3, p11.Y);

            Vector2 p66 = new Vector2(p60.X, p0p.Y - p60.Y);
            Vector2 p67 = new Vector2(p61.X, p0p.Y - p61.Y);

            Vector2 p64 = new Vector2(p42.X - s / 5, p61.Y);
            Vector2 p65 = fun.Inters(p40, p41p, p64, fun.Polar(p64, 0.5 * pi, 100));
            Vector2 p70 = new Vector2(p64.X, p0p.Y - p64.Y);
            Vector2 p71 = new Vector2(p65.X, p0p.Y - p65.Y);

            Vector2[] line5 = { p64, p65 };
            fun.drawBLine(dxf, line5, 0.3, contour);
            Vector2[] line8 = { p70, p71 };
            fun.drawBLine(dxf, line8, 0.3, contour);

            Vector2[] cenline1 = { fun.Polar(p0, pi, cw / 2 + 2), fun.Polar(p0, 0, cw / 2 + 2) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);
            Vector2[] cenline2 = { fun.Polar(p0, 0.5 * pi, insl / 2 + 2), fun.Polar(p0, 1.5 * pi, insl / 2 + 2) };
            fun.drawPlinetype(dxf, cenline2, 0.15, center, Linetype.Center);
            Vector2[] cenline3 = { fun.Polar(p0p, pi, 2), fun.Polar(p0p, 0, s1 + 2) };
            fun.drawPlinetype(dxf, cenline3, 0.15, center, Linetype.Center);
            /*
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p5, p20), offset * 1.5, 90, dimensionStyle);
            linedim1.UserText = String.Format("{0}", insl);
            dxf.AddEntity(linedim1);

            LinearDimension linedim2 = new LinearDimension(new Line(p17, p20), offset, 180, dimensionStyle);
            linedim2.UserText = String.Format("{0}", cw);
            dxf.AddEntity(linedim2);

            LinearDimension linedim3 = new LinearDimension(new Line(p15, p17), offset, 270, dimensionStyle);
            linedim3.UserText = String.Format("{0}", pdpt);
            dxf.AddEntity(linedim3);

            LinearDimension linedim4 = new LinearDimension(new Line(p40, p41), offset + (p41.Y - p40.Y) / 2, 0, dimensionStyle);
            linedim4.UserText = String.Format("{0}", s);
            dxf.AddEntity(linedim4);

            LinearDimension linedim5 = new LinearDimension(new Line(p40, p43), offset * 2 + p41.Y / 2 - (p40.Y - p43.Y) / 4, 0, dimensionStyle);
            linedim5.UserText = String.Format("{0}", s1);
            dxf.AddEntity(linedim5);*/

            var height = textsize;//字体高度
            var arrowsize = textsize;//箭头大小
            var exline = 1 ;//延伸线长度


            fun.dimrot1(dxf, p17, p20, 180, offset, 2, height, arrowsize, exline, "CW=" + cw / scale, "", "");
            fun.dimrot1(dxf, p5, p20, 90, offset , 2, height, arrowsize, exline, "INSL=" + insl / scale, "", "");
            fun.jt1(dxf, p20, -135, offset*2  , 3, "re=0", height);



            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }

        public static void InsertTwoCuttingEdgesForPartingSelfClamping(Dictionary<string, Object> data)  //刀片，双切削刃切断，自-夹紧
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;

            double insl = Convert.ToDouble(data["insl"]);
            double bw = Convert.ToDouble(data["bw"]);
            double pdpt = Convert.ToDouble(data["pdpt"]);
            double cw = Convert.ToDouble(data["cw"]);
            double rel = Convert.ToDouble(data["rel"]);
            double rer = Convert.ToDouble(data["rer"]);
            double psirr = Convert.ToDouble(data["psirr"]) * pi / 180;
            double s1 = Convert.ToDouble(data["s1"]);
            double s = Convert.ToDouble(data["s"]);
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            double DIM = Convert.ToDouble(data["dim"]);

            string path = Convert.ToString(data["path"]);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = new Vector2(p0.X - (cw - bw / 2), p0.Y - insl / 2);
            Vector2 p2 = fun.Polar(p1, psirr, cw / Math.Cos(psirr));
            Vector2 p3 = new Vector2(p0.X + cw - bw / 2, p0.Y + insl / 2);
            Vector2 p4 = fun.Polar(p3, pi + psirr, cw / Math.Cos(psirr));
            Vector2 p5 = new Vector2(p2.X, p1.Y + pdpt);
            Vector2 p6 = new Vector2(p4.X, p3.Y - pdpt);
            Vector2 p7 = new Vector2(p2.X, p1.Y + 0.85 * pdpt);
            Vector2 p8 = fun.Polar(p1, pi / 2, fun.CalDistance(p2, p7));
            Vector2 p9 = new Vector2(p4.X, p3.Y - 0.85 * pdpt);
            Vector2 p10 = fun.Polar(p3, 1.5 * pi, fun.CalDistance(p4, p9));
            Vector2 p11 = new Vector2(p0.X, p7.Y);
            Vector2 p12 = new Vector2(p4.X, p11.Y + pdpt / 20);
            Vector2 p13 = new Vector2(p0.X, p0.Y - p11.Y);
            Vector2 p14 = new Vector2(p2.X, p13.Y - pdpt / 20);
            Vector2 p1z = fun.Polar(p1, 0.5 * pi, rel / Math.Tan((0.5 * pi - psirr) / 2));
            Vector2 p1y = fun.Polar(p1, psirr, rel / Math.Tan((0.5 * pi - psirr) / 2));
            Vector2 p2z = fun.Polar(p2, pi + psirr, rer / Math.Tan((0.5 * pi + psirr) / 2));
            Vector2 p2y = fun.Polar(p2, 0.5 * pi, rer / Math.Tan((0.5 * pi + psirr) / 2));
            Vector2 p3z = fun.Polar(p3, pi + psirr, rel / Math.Tan((0.5 * pi - psirr) / 2));
            Vector2 p3y = fun.Polar(p3, 1.5 * pi, rel / Math.Tan((0.5 * pi - psirr) / 2));
            Vector2 p4z = fun.Polar(p4, 1.5 * pi, rer / Math.Tan((0.5 * pi + psirr) / 2));
            Vector2 p4y = fun.Polar(p4, psirr, rer / Math.Tan((0.5 * pi + psirr) / 2));

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1z));
            poly1.Vertexes[0].Bulge = Math.Tan((0.5 * pi + psirr) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p1y));
            poly1.Vertexes.Add(new LwPolylineVertex(p2z));
            poly1.Vertexes[2].Bulge = Math.Tan((0.5 * pi - psirr) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p2y));
            poly1.Vertexes.Add(new LwPolylineVertex(p14));
            poly1.Vertexes.Add(new LwPolylineVertex(p10));
            poly1.Vertexes.Add(new LwPolylineVertex(p3y));
            poly1.Vertexes[6].Bulge = Math.Tan((0.5 * pi + psirr) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p3z));
            poly1.Vertexes.Add(new LwPolylineVertex(p4y));
            poly1.Vertexes[8].Bulge = Math.Tan((0.5 * pi - psirr) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p4z));
            poly1.Vertexes.Add(new LwPolylineVertex(p12));
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p1z));
            fun.PolyFill(dxf, poly1, 0.3, contour);

            Vector2[] line1 = { p7, p8 };
            fun.drawBLine(dxf, line1, 0.3, contour);
            Vector2[] line2 = { p9, p10 };
            fun.drawBLine(dxf, line2, 0.3, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p5));
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            fun.PolyFill(dxf, poly2, 0.3, contour);
            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p6));
            poly3.Vertexes.Add(new LwPolylineVertex(p13));
            poly3.Vertexes.Add(new LwPolylineVertex(p14));
            fun.PolyFill(dxf, poly3, 0.3, contour);

            Vector2 p0p = fun.Polar(p0, 0, 50);
            Vector2 p21 = new Vector2(p0p.X, p3.Y - 0.5 * pdpt);
            Vector2 p24 = new Vector2(p0p.X + s, p3.Y);
            Vector2 p22 = new Vector2(p21.X + 0.7 * s, p21.Y + 0.25 * pdpt);
            Vector2 p23 = fun.Polar(p24, pi + an, 0.2 * s);
            Vector2 p25 = fun.Polar(p24, 1.5 * pi - gan, 0.3 * pdpt);
            Vector2 p26 = new Vector2(p0p.X + s1, p13.Y);
            Vector2 p27 = new Vector2(p26.X, p0p.Y - p26.Y);
            Vector2 p28 = new Vector2(p25.X, p0p.Y - p25.Y);
            Vector2 p29 = new Vector2(p24.X, p0p.Y - p24.Y);
            Vector2 p30 = new Vector2(p23.X, p0p.Y - p23.Y);
            Vector2 p31 = new Vector2(p22.X, p0p.Y - p22.Y);
            Vector2 p32 = new Vector2(p21.X, p0p.Y - p21.Y);

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p21));
            poly4.Vertexes.Add(new LwPolylineVertex(p22));
            poly4.Vertexes.Add(new LwPolylineVertex(p23));
            poly4.Vertexes.Add(new LwPolylineVertex(p24));
            poly4.Vertexes.Add(new LwPolylineVertex(p25));
            poly4.Vertexes[4].Bulge = Math.Tan(pi / 8);
            poly4.Vertexes.Add(new LwPolylineVertex(p26));
            poly4.Vertexes.Add(new LwPolylineVertex(p27));
            poly4.Vertexes[6].Bulge = Math.Tan(pi / 8);
            poly4.Vertexes.Add(new LwPolylineVertex(p28));
            poly4.Vertexes.Add(new LwPolylineVertex(p29));
            poly4.Vertexes.Add(new LwPolylineVertex(p30));
            poly4.Vertexes.Add(new LwPolylineVertex(p31));
            poly4.Vertexes.Add(new LwPolylineVertex(p32));
            poly4.Vertexes.Add(new LwPolylineVertex(p21));
            fun.PolyFill(dxf, poly4, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            if (DIM == 0)
            {
                LinearDimension linedim1 = new LinearDimension(new Line(p1, p3), offset * 2 + (p3.X - p1.X) / 2, 90, dimensionStyle);
                linedim1.UserText = "INSL";
                dxf.AddEntity(linedim1);

                LinearDimension linedim2 = new LinearDimension(new Line(p1, new Vector2(p0.X, p5.Y)), offset + (p0.X - p1.X) / 2, 90, dimensionStyle);
                linedim2.UserText = "PDPT";
                dxf.AddEntity(linedim2);

                LinearDimension linedim3 = new LinearDimension(new Line(p1, p2), offset + (p2.Y - p1.Y) / 2, 180, dimensionStyle);
                linedim3.UserText = "CW";
                dxf.AddEntity(linedim3);

                LinearDimension linedim4 = new LinearDimension(new Line(p21, p26), offset + (p26.X - p21.X) / 2, 0, dimensionStyle);
                linedim4.UserText = "S1";
                dxf.AddEntity(linedim4);

                LinearDimension linedim5 = new LinearDimension(new Line(p32, p29), offset + (p29.X - p32.X) / 2, 180, dimensionStyle);
                linedim5.UserText = "S";
                dxf.AddEntity(linedim5);
            }
            else
            {
                LinearDimension linedim1 = new LinearDimension(new Line(p1, p3), offset * 2 + (p3.X - p1.X) / 2, 90, dimensionStyle);
                linedim1.UserText = String.Format("INSL={0}", insl);
                dxf.AddEntity(linedim1);

                LinearDimension linedim2 = new LinearDimension(new Line(p1, new Vector2(p0.X, p5.Y)), offset + (p0.X - p1.X) / 2, 90, dimensionStyle);
                linedim2.UserText = String.Format("PDPT={0}", pdpt);
                dxf.AddEntity(linedim2);

                LinearDimension linedim3 = new LinearDimension(new Line(p1, p2), offset + (p2.Y - p1.Y) / 2, 180, dimensionStyle);
                linedim3.UserText = String.Format("CW={0}", cw);
                dxf.AddEntity(linedim3);

                LinearDimension linedim4 = new LinearDimension(new Line(p21, p26), offset + (p26.X - p21.X) / 2, 0, dimensionStyle);
                linedim4.UserText = String.Format("S1={0}", s1);
                dxf.AddEntity(linedim4);

                LinearDimension linedim5 = new LinearDimension(new Line(p32, p29), offset + (p29.X - p32.X) / 2, 180, dimensionStyle);
                linedim5.UserText = String.Format("S={0}", s);
                dxf.AddEntity(linedim5);
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void InsertTwoCuttingEdgesForProfilingAndPartialThreading(Dictionary<string, Object> data)  //刀片，双切削刃成形和部分螺纹
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            double scale = Convert.ToDouble(data["scale"]);
            //double scale = 2;

            double offset = 10;
            double textsize = 3.5;

            double insl = Convert.ToDouble(data["insl"]) * scale;
            double pna = Convert.ToDouble(data["pna"]) * pi / 180;
            double pal = Convert.ToDouble(data["pal"]) * pi / 180;
            double par = Convert.ToDouble(data["par"]) * pi / 180;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double cre = Convert.ToDouble(data["cre"]) * scale;
            double s = Convert.ToDouble(data["s"]) * scale;
            double s1 = Convert.ToDouble(data["s1"]) * scale;
            double pdpt = Convert.ToDouble(data["pdpt"]) * scale;
            // double pdpt = 0.5 * cw * Math.Tan(0.5 * pi - par); 
            double an = Convert.ToDouble(data["an"]) * pi / 180;

            string path = Convert.ToString(data["path"]);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0p = fun.Polar(p0, 0, insl);
            Vector2 p1 = fun.Polar(p0, 1.5 * pi, insl / 2);
            Vector2 p2 = new Vector2(p1.X + cw / 2, p1.Y + pdpt);
            Vector2 p3 = new Vector2(p0.X + cw / 2, p2.Y + insl / 15);
            Vector2 p4 = new Vector2(p0.X + cw / 2, p0.Y - p3.Y);
            Vector2 p5 = new Vector2(p2.X, p0.Y - p2.Y);
            Vector2 p6 = new Vector2(p1.X, p0.Y - p1.Y);
            Vector2 p7 = new Vector2(p0.X - p5.X, p5.Y);
            Vector2 p8 = new Vector2(p0.X - p4.X, p4.Y);
            Vector2 p9 = new Vector2(p0.X - p3.X, p3.Y);
            Vector2 p10 = new Vector2(p0.X - p2.X, p2.Y);
            Vector2 p11 = new Vector2(p9.X + 0.1 * cw, p9.Y);
            Vector2 p13 = new Vector2(p0.X, p9.Y - 0.1 * cw);
            Vector2 p15 = new Vector2(p3.X - 0.1 * cw, p3.Y);
            Vector2 p16 = new Vector2(p4.X - 0.1 * cw, p4.Y);
            Vector2 p18 = new Vector2(p13.X, p0.Y - p13.Y);
            Vector2 p20 = new Vector2(p11.X, p0.Y - p11.Y);
            Vector2 p12 = fun.Inters(p11, p13, fun.Polar(p0, pi, 0.2 * cw), new Vector2(p0.X - 0.2 * cw, p0.Y - 100));
            Vector2 p14 = new Vector2(p0.X - p12.X, p12.Y);
            Vector2 p17 = new Vector2(p14.X, p0.Y - p14.Y);
            Vector2 p19 = new Vector2(p12.X, p0.Y - p12.Y);
            Vector2 p1z = fun.Polar(p1, 0.5 * pi + pal, cre / Math.Tan(pal));
            Vector2 p1y = fun.Polar(p1, 0.5 * pi - par, cre / Math.Tan(par));
            Vector2 p6z = new Vector2(p1z.X, p0.Y - p1z.Y);
            Vector2 p6y = new Vector2(p1y.X, p0.Y - p1y.Y);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1z));
            poly1.Vertexes[0].Bulge = Math.Tan((pi - pna) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p1y));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6y));
            poly1.Vertexes[4].Bulge = Math.Tan((pi - pna) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p6z));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p10));
            poly1.Vertexes.Add(new LwPolylineVertex(p1z));
            fun.PolyFill(dxf, poly1, 0.3, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p3));
            poly2.Vertexes.Add(new LwPolylineVertex(p4));
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes.Add(new LwPolylineVertex(p18));
            poly2.Vertexes.Add(new LwPolylineVertex(p20));
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes.Add(new LwPolylineVertex(p3));
            fun.PolyFill(dxf, poly2, 0.3, contour);

            Vector2[] line1 = { p2, p10 };
            fun.drawBLine(dxf, line1, 0.3, contour);
            Vector2[] line2 = { p5, p7 };
            fun.drawBLine(dxf, line2, 0.3, contour);
            Vector2[] line3 = { p11, p20 };
            fun.drawBLine(dxf, line3, 0.3, contour);
            Vector2[] line4 = { p12, p19 };
            fun.drawBLine(dxf, line4, 0.3, contour);
            Vector2[] line5 = { p14, p17 };
            fun.drawBLine(dxf, line5, 0.3, contour);
            Vector2[] line6 = { p15, p16 };
            fun.drawBLine(dxf, line6, 0.3, contour);

            Vector2[] cenline1 = { fun.Polar(p1, 1.5 * pi, 1), fun.Polar(p6, 0.5 * pi, 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);
            Vector2[] cenline2 = { fun.Polar(p0, pi, cw / 2 + 2), fun.Polar(p0, 0, cw / 2 + 2) };
            fun.drawPlinetype(dxf, cenline2, 0.15, center, Linetype.Center);
            Vector2[] cenline3 = { fun.Polar(p0p, pi, 1), fun.Polar(p0p, 0, s1 + 1) };
            fun.drawPlinetype(dxf, cenline3, 0.15, center, Linetype.Center);

            Vector2 p30 = fun.Polar(p0p, 0.5 * pi, pdpt);
            Vector2 p31 = fun.Polar(p30, 0.5 * pi, 0.3 * pdpt);
            Vector2 p33 = new Vector2(p0p.X + s, p6.Y);
            Vector2 p32 = fun.Polar(p33, pi + an, 0.8 * s);
            Vector2 p34 = new Vector2(p33.X, p30.Y);
            Vector2 p35 = new Vector2(p0p.X + s1, p4.Y);
            Vector2 p36 = new Vector2(p35.X, p0.Y - p35.Y);
            Vector2 p37 = new Vector2(p34.X, p0.Y - p34.Y);
            Vector2 p38 = new Vector2(p33.X, p0.Y - p33.Y);
            Vector2 p39 = new Vector2(p32.X, p0.Y - p32.Y);
            Vector2 p40 = new Vector2(p31.X, p0.Y - p31.Y);
            Vector2 p41 = new Vector2(p30.X, p0.Y - p30.Y);

            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p31));
            poly3.Vertexes.Add(new LwPolylineVertex(p32));
            poly3.Vertexes.Add(new LwPolylineVertex(p33));
            poly3.Vertexes.Add(new LwPolylineVertex(p34));
            poly3.Vertexes.Add(new LwPolylineVertex(p35));
            poly3.Vertexes.Add(new LwPolylineVertex(p36));
            poly3.Vertexes.Add(new LwPolylineVertex(p37));
            poly3.Vertexes.Add(new LwPolylineVertex(p38));
            poly3.Vertexes.Add(new LwPolylineVertex(p39));
            poly3.Vertexes.Add(new LwPolylineVertex(p40));
            poly3.Vertexes.Add(new LwPolylineVertex(p31));
            fun.PolyFill(dxf, poly3, 0.3, contour);

            Vector2[] line7 = { p30, p34 };
            fun.drawBLine(dxf, line7, 0.3, contour);
            Vector2[] line8 = { p37, p41 };
            fun.drawBLine(dxf, line8, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = textsize ;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = textsize;

            LinearDimension linedim1 = new LinearDimension(new Line(p1, p6), offset +cw/2, -90, dimensionStyle);
            linedim1.UserText = String.Format("INSL={0}", insl/scale );
            dxf.AddEntity(linedim1);

            LinearDimension linedim2 = new LinearDimension(new Line(p2, p10), offset +Math .Abs ( p2.Y-p1.Y), 180, dimensionStyle);
            linedim2.UserText = String.Format("CW={0}", cw / scale);
            dxf.AddEntity(linedim2);

            LinearDimension linedim3 = new LinearDimension(new Line(p30, p33), offset+Math.Abs (p30.Y-p33.Y)/2, 0, dimensionStyle);
            linedim3.UserText = String.Format("S={0}", s / scale);
            dxf.AddEntity(linedim3);

            LinearDimension linedim4 = new LinearDimension(new Line(p30, p35), offset*2 +Math.Abs (p30.Y - p35.Y)/2+p33.Y-p30.Y, 0, dimensionStyle);
            linedim4.UserText = String.Format("S1={0}", s1 / scale);
            dxf.AddEntity(linedim4);

            LinearDimension linedim5 = new LinearDimension(new Line(p37, p38), offset, 270, dimensionStyle);
            linedim5.UserText = String.Format("PDPT={0}", pdpt / scale);
            dxf.AddEntity(linedim5);

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void InsertTwoCuttingEdgesForProfiling(Dictionary<string, Object> data)  //刀片，双切削刃仿形
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            double pi = Math.PI;
            double scale = Convert.ToDouble(data["scale"]);
            //double scale =1;

            double offset = 10;
            double textsize = 3.5;

            double insl = Convert.ToDouble(data["insl"]) * scale;
            double cre = Convert.ToDouble(data["cre"]) * scale;
            double bw = Convert.ToDouble(data["bw"]) * scale;
            double pdpt = Convert.ToDouble(data["pdpt"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double gan = Convert.ToDouble(data["gan"]) * pi / 180;
            double an = Convert.ToDouble(data["an"]) * pi / 180;
            double s = Convert.ToDouble(data["s"]) * scale;
            double s1 = Convert.ToDouble(data["s1"]) * scale;

            string path = Convert.ToString(data["path"]);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = new Vector2(p0.X + bw / 2, p0.Y + 0.5 * insl - cre - Math.Sqrt(Math.Abs(cre * cre - (bw * bw) / 4)));
            Vector2 p2 = new Vector2(p0.X - p1.X, p1.Y);
            Vector2 p3 = new Vector2(p2.X, p0.Y - p2.Y);
            Vector2 p4 = new Vector2(p1.X, p0.Y - p1.Y);
            Vector2 p5 = new Vector2(p1.X, p0.Y + insl / 2 - (s1 - s) / Math.Tan(gan));
            Vector2 p6 = new Vector2(p0.X - p5.X, p5.Y);
            Vector2 p7 = new Vector2(p6.X, p0.Y - p6.Y);
            Vector2 p8 = new Vector2(p5.X, p0.Y - p5.Y);
            double ang1 = Math.Asin(bw / cw);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes[0].Bulge = Math.Tan((2 * pi - 2 * ang1) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes[2].Bulge = Math.Tan((2 * pi - 2 * ang1) / 4);
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            fun.PolyFill(dxf, poly1, 0.3, contour);

            Vector2[] line1 = { p5, p6 };
            fun.drawBLine(dxf, line1, 0.3, contour);
            Vector2[] line2 = { p7, p8 };
            fun.drawBLine(dxf, line2, 0.3, contour);

            Vector2 p0p = fun.Polar(p0, 0, insl * 1.2);
            Vector2 p21 = fun.Polar(p0p, 0.5 * pi, insl * 0.4);
            Vector2 p23 = new Vector2(p0p.X + s, p0p.Y + insl / 2);
            Vector2 p22 = fun.Polar(p23, pi + an, 0.8 * s / Math.Cos(an));
            Vector2 p24 = new Vector2(p0p.X + s1, p5.Y);
            Vector2 p25 = new Vector2(p24.X, p0p.Y - p24.Y);
            Vector2 p26 = new Vector2(p23.X, p0p.Y - p23.Y);
            Vector2 p27 = new Vector2(p22.X, p0p.Y - p22.Y);
            Vector2 p28 = new Vector2(p21.X, p0p.Y - p21.Y);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p21));
            poly2.Vertexes.Add(new LwPolylineVertex(p22));
            poly2.Vertexes.Add(new LwPolylineVertex(p23));
            poly2.Vertexes.Add(new LwPolylineVertex(p24));
            poly2.Vertexes.Add(new LwPolylineVertex(p25));
            poly2.Vertexes.Add(new LwPolylineVertex(p26));
            poly2.Vertexes.Add(new LwPolylineVertex(p27));
            poly2.Vertexes.Add(new LwPolylineVertex(p28));
            poly2.Vertexes.Add(new LwPolylineVertex(p21));
            fun.PolyFill(dxf, poly2, 0.3, contour);

            Vector2 p29 = new Vector2(p21.X, p21.Y - 1);
            Vector2 p30 = fun.Polar(p24, 0.5 * pi + gan, 1);
            Vector2 p31 = new Vector2(p29.X, p0p.Y - p29.Y);
            Vector2 p32 = new Vector2(p30.X, p0p.Y - p30.Y);
            Vector2 p33 = fun.Polar(p23, pi + an, 0.6 * s / Math.Cos(an));
            Vector2 p34 = fun.Inters(p29, p30, p33, fun.Polar(p33, 1.55 * pi, 100));
            Vector2 p35 = fun.Inters(p29, p30, new Vector2(p0p.X + 0.5 * s1, p0p.Y + 50), new Vector2(p0p.X + 0.5 * s1, p0p.Y - 50));
            Vector2 p36 = new Vector2(p35.X, p0p.Y - p35.Y);
            Vector2 p37 = new Vector2(p34.X, p0p.Y - p34.Y);
            Vector2 p38 = new Vector2(p33.X, p0p.Y - p33.Y);

            Vector2[] line3 = { p29, p30 };
            fun.drawBLine(dxf, line3, 0.3, contour);
            Vector2[] line4 = { p31, p32 };
            fun.drawBLine(dxf, line4, 0.3, contour);
            Vector2[] line5 = { p33, p34 };
            fun.drawBLine(dxf, line5, 0.3, contour);
            Vector2[] line6 = { p35, p36 };
            fun.drawBLine(dxf, line6, 0.3, contour);
            Vector2[] line7 = { p37, p38 };
            fun.drawBLine(dxf, line7, 0.3, contour);

            Vector2[] cenline1 = { fun.Polar(p0, pi / 2, insl / 2 + 1), fun.Polar(p0, 1.5 * pi, insl / 2 + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, center, Linetype.Center);
            Vector2[] cenline2 = { fun.Polar(p0, pi, bw / 2 + 1), fun.Polar(p0, 0, bw / 2 + 1) };
            fun.drawPlinetype(dxf, cenline2, 0.15, center, Linetype.Center);
            Vector2[] cenline3 = { fun.Polar(p0p, pi, 1), fun.Polar(p0p, 0, s1 + 1) };
            fun.drawPlinetype(dxf, cenline3, 0.15, center, Linetype.Center);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = textsize;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = textsize;

            LinearDimension linedim1 = new LinearDimension(new Line(fun.Polar(p0, pi / 2, insl / 2), fun.Polar(p0, 1.5 * pi, insl / 2)), offset*2+cw /2, -90, dimensionStyle);
            linedim1.UserText = String.Format("INSL={0}", insl/scale );
            dxf.AddEntity(linedim1);

            LinearDimension linedim2 = new LinearDimension(new Line(new Vector2(p0.X - cre, p0.Y - insl / 2 + cre), new Vector2(p0.X + cre, p0.Y - insl / 2 + cre)), offset +cre, 180, dimensionStyle);
            linedim2.UserText = String.Format("CW={0}", cw/scale );
            dxf.AddEntity(linedim2);

            LinearDimension linedim3 = new LinearDimension(new Line(fun.Polar(p0, 1.5 * pi, insl / 2), new Vector2(p0.X + cre, p0.Y - insl / 2 + cre)), offset+cw/4, 270, dimensionStyle);
            linedim3.UserText = String.Format("PDPT={0}", pdpt/scale );
            dxf.AddEntity(linedim3);

            LinearDimension linedim4 = new LinearDimension(new Line(p28, p26), offset + Math.Abs(p26.Y - p28.Y) / 2, 180, dimensionStyle);
            linedim4.UserText = String.Format("S={0}", s/scale);
            dxf.AddEntity(linedim4);

            LinearDimension linedim5 = new LinearDimension(new Line(p25, p28), offset * 2 + Math.Abs(p25.Y - p28.Y) / 2 + p28.Y - p26.Y, 180, dimensionStyle);
            linedim5.UserText = String.Format("S1={0}", s1/scale );
            dxf.AddEntity(linedim5);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Shankconnectedendmill(Dictionary<string, Object> data)  //整体非中心(整体中心)切削立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //  double sl = Convert.ToDouble(data["oal"]);
            double sl = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);
            /*
                double sl = 84.5;
                double scale = 1;
                */
            if (sl <= 50)
            {
                scale = 2.2;
            }
            else if (50 < sl && sl <= 75)
            {
                scale = 1.8;
            }
            else if (75 < sl && sl <= 100)
            {
                scale = 1.4;
            }
            else
            {
                scale = 1;
            }
            /*
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double d = 10 * scale;
            double lh = 48 * scale;
            double lu = 60.6 * scale;
            double oal = 84.5 * scale;
            double dconms = 12 * scale;
            double ls = 21.9 * scale;
            double dc = 11.5 * scale;
            double lpr = 63 * scale;
            double Z = 5 - 2;//齿数
            double x = 1;
            double a = 0.5 * scale;//倒角
            double fha = 30;
            double fha_ = fha * pi / 180;
            double kapr = 85;
            double kapr_ = kapr * pi / 180;
            */

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double d = Convert.ToDouble(data["dn"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double x = Convert.ToDouble(data["x"]);
            double Z = Convert.ToDouble(data["zefp"]) - 1;//齿数
            double a = Convert.ToDouble(data["ec"]) * scale;//倒角
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double kapr = Convert.ToDouble(data["kapr"]);
            double kapr_ = kapr * pi / 180;
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_ = fun.Polar(p0, pi, oal + 5);
            Vector2 p0_1 = fun.Polar(p0, 0, oal - lh + 1);
            Vector2 p1 = fun.Polar(p0, pi - 0.81120299, d * (0.14627067 / 1));
            Vector2 p1_ = fun.Polar(p1, pi, 500);
            Vector2 p2 = new Vector2(p0.X, -d * (0.16812936 / 1));
            Vector2 p4 = fun.Polar(p0, pi / -2, d / 2.0);
            Vector2 p3 = new Vector2(0, d / 2.0);
            Vector2 p3_ = fun.Polar(p3, pi / -2, 300);
            Vector2 p3_01 = new Vector2(p3.X - 300, p3.Y);
            Vector2 p10_ = fun.Polar(p3, pi + fha_, 500);
            Vector2 p10 = fun.Inters(p3, p10_, p0, p0_);
            Arc arc3 = fun.DrawArc4(p3, 1.22 / 1 * d, p10, 0);
            Vector2 p6_ = fun.Polar(p1, pi, 500);
            Vector2 p6 = fun.Inters1(p6_, p1, arc3, 0);
            Vector2 p5 = fun.Polar(p6, 0, 0.13 / 1 * d);
            Vector2 p8 = fun.Polar(p4, pi + 0.08002114, 0.70920754 / 1 * d);
            Vector2 p8_ = fun.Polar(p8, pi, 300);
            double v6_5 = fun.CalDistance(p6, p5);
            Vector2 p9 = fun.Polar(p10, 0, v6_5);
            Vector2 p9_ = fun.Polar(p9, pi + fha_, 300);
            Vector2 p12 = fun.Polar(p8, pi - 0.09587523, 0.64141766 / 1.0 * d);
            Vector2 p13 = fun.Inters(p8, p8_, p9, p9_);
            Vector2 p13_ = fun.Polar(p13, pi - 0.52141547, 300);
            Arc arc2 = fun.DrawArc4(p13, 1.79 / 1 * d, p9, 0);
            Vector2 p11_ = fun.Polar(p8, pi - 0.53086055, 500);
            Vector2 p11 = fun.Inters1(p8, p11_, arc2, 1);
            Vector2 p16 = fun.Polar(p10, pi, 0.82792183 / 1 * d);//需修改
            Vector2 p16_ = fun.Polar(p16, pi + 0.56179010, 300); //需修改
                                                                 // System.Diagnostics.Debug.WriteLine(-0.49068496*180/pi);
                                                                 // System.Diagnostics.Debug.WriteLine(10000000001);
            double v8_13 = fun.CalDistance(p8, p13);
            Vector2 p15 = fun.Inters(p8, p8_, p16, p16_);
            Arc arc6 = fun.DrawArc4(p15, 1.46 / 1 * d, p16, 0);
            Vector2 p14 = fun.Inters1(p13, p13_, arc6, 1);
            Arc arc5 = fun.DrawArc4(p3, 1.69 / 1 * d, p16, 0);
            Arc arc7 = fun.DrawArc4(p2, 0.15788544 / 1.0 * d, p1, 0);
            Vector2 p17 = fun.Inters1(p3, p3_, arc7, 0);
            Vector2 p17_ = fun.Inters1(p3, p3_01, arc5, 0);
            double v1 = fun.CalDistance(p3, p17_);
            System.Diagnostics.Debug.WriteLine(v1);
            System.Diagnostics.Debug.WriteLine(50003);
            double ang1 = fun.CalAngle(p3, p17_);
            double v2 = fun.CalDistance(p3, p10);
            double ang2 = fun.CalAngle(p3, p10);
            double v3 = fun.CalDistance(p10, p13);
            double v7 = fun.CalDistance(p10, p13);
            double ang3 = fun.CalAngle(p10, p13);
            double v4 = fun.CalDistance(p10, p16);
            double ang4 = fun.CalAngle(p10, p16);
            double v5 = fun.CalDistance(p13, p14);
            double ang5 = fun.CalAngle(p13, p14);
            double v6 = fun.CalDistance(p16, p15);
            double ang6 = fun.CalAngle(p16, p15);



            for (double i = v1; i < v1 * Z; i += v1)
            {

                Vector2 p1_1 = new Vector2(-i, d / 2.0);//17
                Vector2 p2_1 = fun.Polar(p1_1, ang2, v2);
                Vector2 p3_1 = fun.Polar(p2_1, ang3, v3);
                Vector2 p3_2 = fun.Polar(p3_01, ang5, 300);
                Vector2 p4_1 = fun.Polar(p2_1, ang4, v4);
                Vector2 p6_1 = fun.Polar(p4_1, ang6, v6);
                Arc arc3_ = fun.DrawArc4(p6_1, 1.46 / 1 * d, p4_1, 0);
                Vector2 p5_1 = fun.Inters1(p3_1, p3_2, arc3_, 1);
                Arc arc1_ = fun.DrawArc4(p1_1, 1.22 / 1 * d, p2_1, 0);
                Arc arc2_ = fun.DrawArc4(p3_1, 1.79 / 1 * d, p2_1, 0);
                Line line1_ = new Line(p3_1, p5_1);
                Arc arc4_ = fun.DrawArc4(p1_1, 1.69 / 1 * d, p4_1, 0);

                /* Line line100 = new Line(p6_1, p4_1);
                 fun.drawBline(dxf, line100, 0.5, contour);*/
                //dxf.AddEntity(new EntityObject[] { arc1_, arc2_, arc3_, arc4_, line1_ });
                fun.drawBArc(dxf, arc1_, 0.5, contour);
                fun.drawBArc(dxf, arc2_, 0.5, contour);
                fun.drawBArc(dxf, arc3_, 0.5, contour);
                fun.drawBArc(dxf, arc4_, 0.5, contour);
                fun.drawBline(dxf, line1_, 0.5, contour);


            }

            if (Z != 3)
            {
                //lh = Convert.ToDouble(data["lh"]) * scale + v1 * (Z - 3);
                lh = 48 * scale + v1 * (Z - 3);
            }
            Vector2 p20 = new Vector2(-v1 * Z, d / 2.0);

            Vector2 p20_ = fun.Polar(p20, pi + fha_, 300);
            Vector2 p21 = fun.Inters(p20, p20_, p0, p0_);
            Arc arc10 = fun.DrawArc4(p20, 1.22 / 1 * d, p21, 0);

            Vector2 p23 = new Vector2(-lh, 0);
            Vector2 p23_ = fun.Polar(p23, pi / 2 - (pi / 2 - kapr_), 300);
            Vector2 p22 = new Vector2(p23.X, p15.Y);
            Arc arc11 = fun.DrawArc4(p22, 13.71296875 / 10 * d, p21, 0);
            Arc arc12 = fun.DrawArc4(p20, 27.01964943 / 10 * d, p23, 0);
            /*  Line line120 = new Line(p22, p21);
              Line line121 = new Line(p20, p23);
              dxf.AddEntity(new EntityObject[] { line120 ,line121 });
            */
            Vector2 p20_1 = fun.Polar(p20, pi, 200);
            Vector2 p24 = fun.Inters1(p20, p20_1, arc12, 0);
            Vector2 p25 = fun.Polar(p23, pi / 2 - (pi / 2 - kapr_), 3.49680805 / 10 * d);

            double ang10 = fun.CalAngle(p23, p25);
            double v10 = fun.CalDistance(p23, p25);
            Arc arc16 = fun.DrawArc4(p22, 0.7157 / 1 * d, p23, 0);
            Vector2 p26 = fun.Polar(p23, ang10, 0.26 * d);
            Arc arc17 = fun.DrawArc4(p24, 23.50053096 / 10 * d, p26, 0);
            Arc arc8 = fun.DrawArc4(p8, 1.74026492 / 1.0 * d, p2, 0);
            Arc arc9 = fun.DrawArc4(p4, 2.21916736 / 1.0 * d, p8, 0);
            Vector2 p24_ = fun.Inters1(p25, fun.Polar(p25, 0.14020756, 200), arc17, 0);
            double v11 = fun.CalDistance(p26, p25);
            double ang11 = fun.CalAngle(p25, p24);
            double ang12 = fun.CalAngle(p25, p23);
            double ang13 = fun.CalAngle(p22, p23);
            double v13 = fun.CalDistance(p22, p23);
            Vector2 p27 = fun.Polar(p26, ang10, v11 / 2.0);
            Vector2 p27_ = fun.Polar(p27, pi - pi / 4, 300);
            Vector2 p28 = fun.Inters(p27, p27_, p23, fun.Polar(p23, pi / 2, 300));
            Vector2 p29 = new Vector2(p28.X, dc / 2.0);
            Vector2 p30 = fun.Polar(p25, ang11, 3.23921838 / 10 * d);
            Arc arc18 = fun.DrawArc4(p30, 0.79548631 / 1 * d, p29, 0);
            Vector2 p31 = fun.Polar(p22, ang13, v13 / 2.0);
            Vector2 p31_ = fun.Polar(p31, pi / -2 + (ang12 - ang11), 50);
            Vector2 p32 = fun.Inters1(p31, p31_, arc16, 1);
            Line line1 = new Line(p8, p11);
            Line line2 = new Line(p5, p1);
            Line line3 = new Line(p3, p17);
            Line line4 = new Line(p13, p14);
            Line line5 = new Line(p2, p4);
            Line line7 = new Line(p25, p23);
            Line line8 = new Line(p27, p28);
            Line line9 = new Line(p28, p29);
            // Line line10 = new Line(p30, fun.Polar(p30, pi / 2, 50));
            Line line11 = new Line(p31, p32);
            Line line12 = new Line(p31, p22);
            Line line33 = new Line(p25, p24_);
            Arc arc1 = fun.DrawArc4(p5, 1.79 / 1 * d, p9, 0);
            // Arc arc2 = fun.DrawArc4(p9,1.79 , p13,0);           
            Arc arc4 = fun.DrawArc4(p13, 1.71 / 1 * d, p10, 0);
            double v100 = fun.CalDistance(p22, p29);
            Vector2 p33 = fun.Polar(p3, 0, oal - ls - lh - (oal - lu - ls) * 2);
            Vector2 p33_ = fun.Polar(p33, pi / 4, 50);
            Vector2 p33_1 = fun.Polar(p0, pi / 2, dconms / 2);
            Vector2 p33_2 = fun.Polar(p33_1, pi, 50);
            Vector2 p34 = fun.Inters(p33, p33_, p33_1, p33_2);
            Vector2 p35 = fun.Polar(p34, 0, ls - (a / Math.Sqrt(2)));
            Vector2 p36 = fun.Polar(p35, pi / 4, a);
            Vector2 p37 = fun.mirrorpoint(p33, p0_, p0_1);
            Vector2 p38 = fun.mirrorpoint(p34, p0_, p0_1);
            Vector2 p39 = fun.mirrorpoint(p35, p0_, p0_1);
            Vector2 p40 = fun.mirrorpoint(p36, p0_, p0_1);
            Line line13 = new Line(p35, p36);
            Line line14 = new Line(p40, p39);
            Line line15 = new Line(p36, p40);
            Line line16 = new Line(p33, p3);
            Line line17 = new Line(p37, p4);
            // dxf.AddEntity(new EntityObject[] { line1, line2, line3, line4,line5,line7,line8,line9,line11,line12,line13,line14,line16,
            // line17,line15,line33 ,arc1 ,arc2 ,arc3 ,arc4 ,arc5 ,arc6 ,arc7,arc8,arc9,arc10,arc11,arc12,arc16,arc17,arc18});
            fun.drawBline(dxf, line3, 0.5, contour);
            fun.drawBline(dxf, line1, 0.5, contour);
            fun.drawBline(dxf, line2, 0.5, contour);
            fun.drawBline(dxf, line4, 0.5, contour);
            fun.drawBline(dxf, line5, 0.5, contour);
            //fun.drawBline(dxf, line6, 0.5, contour);
            fun.drawBline(dxf, line7, 0.5, contour);
            fun.drawBline(dxf, line8, 0.5, contour);
            fun.drawBline(dxf, line9, 0.5, contour);
            fun.drawBline(dxf, line11, 0.5, contour);
            fun.drawBline(dxf, line12, 0.5, contour);
            fun.drawBline(dxf, line13, 0.5, contour);
            fun.drawBline(dxf, line14, 0.5, contour);
            fun.drawBline(dxf, line16, 0.5, contour);
            fun.drawBline(dxf, line15, 0.5, contour);
            fun.drawBline(dxf, line17, 0.5, contour);
            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            fun.drawBArc(dxf, arc5, 0.5, contour);
            fun.drawBArc(dxf, arc6, 0.5, contour);
            fun.drawBArc(dxf, arc7, 0.5, contour);
            fun.drawBArc(dxf, arc8, 0.5, contour);
            fun.drawBArc(dxf, arc9, 0.5, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            fun.drawBArc(dxf, arc11, 0.5, contour);
            fun.drawBArc(dxf, arc12, 0.5, contour);
            fun.drawBArc(dxf, arc16, 0.5, contour);
            fun.drawBArc(dxf, arc17, 0.5, contour);
            fun.drawBArc(dxf, arc18, 0.5, contour);
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p35));
            poly1.Vertexes.Add(new LwPolylineVertex(p39));
            poly1.Vertexes.Add(new LwPolylineVertex(p38));
            poly1.Vertexes.Add(new LwPolylineVertex(p37));
            poly1.Vertexes.Add(new LwPolylineVertex(p33));
            poly1.Vertexes.Add(new LwPolylineVertex(p34));
            poly1.Vertexes.Add(new LwPolylineVertex(p38));
            poly1.Vertexes.Add(new LwPolylineVertex(p34));
            poly1.Vertexes.Add(new LwPolylineVertex(p35));
            //dxf.AddEntity(poly1);
            fun.PolyFill(dxf, poly1, 0.5, contour);

            Vector2 p41 = new Vector2(p23.X, p23.Y - 5 * dc);
            if (x == 0)
            {
                //右视图               
                Vector2 p42 = fun.Polar(p41, pi / 2, dc / 2.0 * scale * 1.5);
                Vector2 p43 = fun.Polar(p41, 0, 0.9733 / 1.15 * (dc / 2.0) * scale * 1.5);
                Vector2 p44 = fun.Polar(p41, pi / 2, 0.1748 / 1.15 * (dc / 2.0) * scale * 1.5);
                Vector2 p45 = fun.Polar(p44, 0, 0.191 / 1.15 * (dc / 2.0) * scale * 1.5);
                Vector2 p45_ = fun.Polar(p45, pi / 2, 300);
                Vector2 p45_1 = fun.Polar(p45, pi / -6, 300);

                Ellipse ellipse00 = new Ellipse(p41, dc * scale * 1.5, 0.9733 / 1.15 * (dc) * scale * 1.5);//椭圆
                ellipse00.Rotation = 90;
                ellipse00.EndAngle = 0;
                ellipse00.StartAngle = -90;
                ellipse00.Layer = contour;
                ellipse00.Lineweight = Lineweight.W50;
                dxf.AddEntity(ellipse00);
                Vector2 p46 = fun.Polar(p45, pi / 2, 0.47641969 / 1.15 * dc * scale * 1.5);
                Vector2 p47 = fun.Inters(p45, p45_1, p41, p43);
                Arc arc20 = fun.DrawArc4(p44, 0.1266 / 1.15 * dc * scale * 1.5, p41, 0);
                Line line18 = new Line(p44, p42);
                Line line19 = new Line(p44, p45);
                Line line20 = new Line(p45, p47);
                Line line21 = new Line(p45, p46);
                dxf.AddEntity(new EntityObject[] { arc20, line18, line20, line21 });
                fun.drawBArc(dxf, arc20, 0.5, contour);
                fun.drawBline(dxf, line18, 0.5, contour);
                fun.drawBline(dxf, line20, 0.5, contour);
                fun.drawBline(dxf, line21, 0.5, contour);

                for (double g = 0; g < 2 * pi; g += pi / 2)
                {
                    Vector2 p48 = fun.PointRotate(p41, p42, g);
                    Vector2 p49 = fun.PointRotate(p41, p43, g);
                    Vector2 p50 = fun.PointRotate(p41, p44, g);
                    Vector2 p55 = fun.PointRotate(p41, p45, g);
                    Ellipse ellipse01 = new Ellipse(p41, dc * scale * 1.5, 0.9733 / 1.15 * (dc) * scale * 1.5);//椭圆
                    ellipse01.Rotation = g * 180 / pi;
                    ellipse01.EndAngle = 0;
                    ellipse01.StartAngle = -90;
                    ellipse01.Layer = contour;
                    ellipse01.Lineweight = Lineweight.W50;
                    dxf.AddEntity(ellipse01);
                    Vector2 p56 = fun.PointRotate(p41, p46, g);
                    Vector2 p57 = fun.PointRotate(p41, p47, g);
                    Arc arc24 = fun.DrawArc4(p50, 0.1266 / 1.15 * dc * scale * 1.5, p41, 0);
                    Line line22 = new Line(p50, p48);
                    Line line23 = new Line(p50, p55);
                    Line line24 = new Line(p55, p57);
                    Line line25 = new Line(p55, p56);
                    // dxf.AddEntity(new EntityObject[] {  arc24, line22, line23, line24, line25 });
                    fun.drawBArc(dxf, arc24, 0.5, contour);
                    fun.drawBline(dxf, line23, 0.5, contour);
                    fun.drawBline(dxf, line24, 0.5, contour);
                    fun.drawBline(dxf, line22, 0.5, contour);
                    fun.drawBline(dxf, line25, 0.5, contour);
                }
            }
            else
            {

                Vector2 p42 = fun.Polar(p41, pi / 2, dc / 2.0 * scale * 1.5);
                Vector2 p43 = fun.Polar(p41, 0, 6 / 11.5 * dc * scale * 1.5);
                Vector2 p44 = fun.Polar(p41, pi / -2, dc / 2.0 * scale * 1.5);
                Vector2 p45 = fun.Polar(p41, 44 * pi / 180, 1.6 / 11.5 * dc * scale * 1.5);
                Vector2 p46 = fun.Polar(p45, 0, 3.68045999 / 11.5 * dc * scale * 1.5);
                Vector2 p47 = fun.Polar(p41, 44 * pi / 180, 0.7 / 11.5 * dc * scale * 1.5);
                Vector2 p48 = fun.Polar(p47, pi / 2, 0.78 / 11.5 * dc * scale * 1.5);
                Vector2 p49 = fun.Polar(p47, pi / 2, 4.85868046 / 11.5 * dc * scale * 1.5);
                Vector2 p50 = fun.Polar(p49, -0.54695181, 0.95680676 / 11.5 * dc * scale * 1.5);
                Arc arc19 = fun.DrawArc4(p49, 0.67019646 / 11.5 * dc * scale * 1.5, p50, 0);
                Arc arc20 = fun.DrawArc4(p46, 5.2078496 / 11.5 * dc * scale * 1.5, p50, 0);
                Vector2 p48_ = fun.Polar(p48, 44 * pi / 180, 100);
                Vector2 p51 = fun.Inters1(p48, p48_, arc20, 1);
                Vector2 p52 = fun.Polar(p45, -46 * pi / 180, 0.8 / 11.5 * dc * scale * 1.5);
                Vector2 p53 = fun.Polar(p52, -0.67664600, 0.85595237 / 11.5 * dc * scale * 1.5);
                Vector2 p54 = fun.Polar(p53, -pi / 3, 0.7 / 11.5 * dc * scale * 1.5);
                Vector2 p55 = fun.Polar(p43, pi + 0.93504669, 0.77054076 / 11.5 * dc * scale * 1.5);
                Arc arc21 = fun.DrawArc4(p55, 0.51505356 / 11.5 * dc * scale * 1.5, p43, 0);
                Vector2 p56_ = fun.Polar(p54, 0, 200);
                Vector2 p56 = fun.Inters1(p54, p56_, arc21, 1);
                Vector2 p56_01 = fun.Polar(p53, 0, 2.21108363 / 11.5 * dc * scale * 1.5);
                Vector2 p57 = fun.Polar(p52, pi / -2, 5.0319678 / 11.5 * dc * scale * 1.5);
                Arc arc22 = fun.DrawArc4(p57, 4.26408454 / 11.5 * dc * scale * 1.5, p56, 0);
                Arc arc23 = fun.DrawArc4(p46, 1.60060104 / 11.5 * dc * scale * 1.5, p56_01, 0);
                Vector2 p58_ = fun.Polar(p54, -pi / 3, 200);
                Vector2 p588 = fun.Inters1(p54, p58_, arc22, 1);
                Vector2 p599 = fun.Polar(p41, pi / -2, 3.5 / 11.5 * dc * scale * 1.5);
                Arc arc24 = fun.DrawArc4(p57, 2.12128003 / 11.5 * dc * scale * 1.5, p599, 0);
                Arc arc25 = fun.DrawArc4(p49, 0.91653908 / 11.5 * dc * scale * 1.5, p42, 0);
                Arc arc25_ = fun.DrawArc4(p52, 1.03621683 / 11.5 * dc * scale * 1.5, p53, 0);
                Line line22 = new Line(p41, p42);
                Line line23 = new Line(p41, p45);
                Line line24 = new Line(p47, p49);
                Line line25 = new Line(p48, p51);
                Line line50 = new Line(p45, p46);
                Line line51 = new Line(p45, p52);
                Line line52 = new Line(p41, p44);
                Line line53 = new Line(p52, p57);
                Line line54 = new Line(p53, p588);
                Line line55 = new Line(p54, p56);
                Line line56 = new Line(p53, p43);

                Vector2 p102 = fun.PointRotate(p41, p42, pi);
                Vector2 p103 = fun.PointRotate(p41, p43, pi);
                Vector2 p104 = fun.PointRotate(p41, p44, pi);
                Vector2 p105 = fun.PointRotate(p41, p45, pi);
                Vector2 p106 = fun.PointRotate(p41, p46, pi);
                Vector2 p107 = fun.PointRotate(p41, p47, pi);
                Vector2 p108 = fun.PointRotate(p41, p48, pi);
                Vector2 p109 = fun.PointRotate(p41, p49, pi);
                Vector2 p110 = fun.PointRotate(p41, p50, pi);
                Arc arc26 = fun.DrawArc4(p109, 0.67019646 / 11.5 * dc * scale * 1.5, p110, 0);
                Arc arc27 = fun.DrawArc4(p106, 5.2078496 / 11.5 * dc * scale * 1.5, p110, 0);
                Vector2 p108_ = fun.PointRotate(p41, p48_, pi);
                Vector2 p111 = fun.PointRotate(p41, p51, pi);
                Vector2 p112 = fun.PointRotate(p41, p52, pi);
                Vector2 p113 = fun.PointRotate(p41, p53, pi);
                Vector2 p114 = fun.PointRotate(p41, p54, pi);
                Vector2 p115 = fun.PointRotate(p41, p55, pi);
                Arc arc28 = fun.DrawArc4(p115, 0.51505356 / 11.5 * dc * scale * 1.5, p103, 0);
                Vector2 p116_ = fun.PointRotate(p41, p56_, pi);
                Vector2 p116 = fun.PointRotate(p41, p56, pi);
                Vector2 p116_01 = fun.PointRotate(p41, p56_01, pi);
                Vector2 p117 = fun.PointRotate(p41, p57, pi);
                Arc arc29 = fun.DrawArc4(p117, 4.26408454 / 11.5 * dc * scale * 1.5, p116, 0);
                Arc arc30 = fun.DrawArc4(p106, 1.60060104 / 11.5 * dc * scale * 1.5, p116_01, 0);
                Vector2 p118_ = fun.PointRotate(p41, p58_, pi);
                Vector2 p118 = fun.PointRotate(p41, p588, pi);
                Vector2 p119 = fun.PointRotate(p41, p599, pi);
                Arc arc31 = fun.DrawArc4(p117, 2.12128003 / 11.5 * dc * scale * 1.5, p119, 0);
                Arc arc32 = fun.DrawArc4(p109, 0.91653908 / 11.5 * dc * scale * 1.5, p102, 0);
                Arc arc32_ = fun.DrawArc4(p112, 1.03621683 / 11.5 * dc * scale * 1.5, p113, 0);
                Line line57 = new Line(p41, p102);
                Line line58 = new Line(p41, p105);
                Line line59 = new Line(p107, p109);
                Line line60 = new Line(p108, p111);
                Line line61 = new Line(p105, p106);
                Line line62 = new Line(p105, p112);
                Line line63 = new Line(p41, p104);
                Line line64 = new Line(p112, p117);
                Line line65 = new Line(p113, p118);
                Line line66 = new Line(p114, p116);
                Line line67 = new Line(p113, p103);

                /*
                                dxf.AddEntity(new EntityObject[] { line22,line23,line24,line25,line50,line51,line52,line53,line54,line55,line56,line57,
                                    line58,line59,line60,line61,line62,line63,line64,line65,line66,line67
                                ,arc19,arc20,arc21,arc22,arc23,arc24,arc25,arc25_,arc26,arc27,arc28,arc29,arc30,arc31,arc32,arc32_});
                */
                fun.drawBline(dxf, line22, 0.5, contour);
                fun.drawBline(dxf, line23, 0.5, contour);
                fun.drawBline(dxf, line24, 0.5, contour);
                fun.drawBline(dxf, line25, 0.5, contour);
                fun.drawBline(dxf, line50, 0.5, contour);
                fun.drawBline(dxf, line51, 0.5, contour);
                fun.drawBline(dxf, line52, 0.5, contour);
                fun.drawBline(dxf, line53, 0.5, contour);
                fun.drawBline(dxf, line54, 0.5, contour);
                fun.drawBline(dxf, line55, 0.5, contour);
                fun.drawBline(dxf, line56, 0.5, contour);
                fun.drawBline(dxf, line57, 0.5, contour);
                fun.drawBline(dxf, line58, 0.5, contour);
                fun.drawBline(dxf, line59, 0.5, contour);
                fun.drawBline(dxf, line60, 0.5, contour);
                fun.drawBline(dxf, line61, 0.5, contour);
                fun.drawBline(dxf, line62, 0.5, contour);
                fun.drawBline(dxf, line63, 0.5, contour);
                fun.drawBline(dxf, line64, 0.5, contour);
                fun.drawBline(dxf, line65, 0.5, contour);
                fun.drawBline(dxf, line66, 0.5, contour);
                fun.drawBline(dxf, line67, 0.5, contour);
                fun.drawBArc(dxf, arc19, 0.5, contour);
                fun.drawBArc(dxf, arc20, 0.5, contour);
                fun.drawBArc(dxf, arc21, 0.5, contour);
                fun.drawBArc(dxf, arc22, 0.5, contour);
                fun.drawBArc(dxf, arc23, 0.5, contour);
                fun.drawBArc(dxf, arc24, 0.5, contour);
                fun.drawBArc(dxf, arc25, 0.5, contour);
                fun.drawBArc(dxf, arc26, 0.5, contour);
                fun.drawBArc(dxf, arc27, 0.5, contour);
                fun.drawBArc(dxf, arc28, 0.5, contour);
                fun.drawBArc(dxf, arc29, 0.5, contour);
                fun.drawBArc(dxf, arc30, 0.5, contour);
                fun.drawBArc(dxf, arc31, 0.5, contour);
                fun.drawBArc(dxf, arc32, 0.5, contour);
                fun.drawBArc(dxf, arc32_, 0.5, contour);
                fun.drawBArc(dxf, arc25_, 0.5, contour);


            }
            Vector2 p60 = fun.Polar(p41, pi / 2, dc / 2.0 * scale * 1.5);
            Vector2 p61 = fun.Polar(p60, pi, dc / 2.0 * scale * 1.5);
            Vector2 p62 = fun.Polar(p60, 0, dc / 2.0 * scale * 1.5);
            Vector2 p63 = fun.Polar(p61, pi / -2, dc * scale * 1.5);
            Vector2 p64 = fun.Polar(p62, pi / -2, dc * scale * 1.5);
            Line line26 = new Line(p61, p62);
            Line line27 = new Line(p62, p64);
            Line line28 = new Line(p63, p64);
            Line line29 = new Line(p63, p61);
            line26.Lineweight = Lineweight.W25;//Lineweight指线宽
            line26.Layer = refin;//Layer指图层
            line26.LinetypeScale = 5 / scale * 1.5;
            line26.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line26);
            line27.Lineweight = Lineweight.W25;//Lineweight指线宽
            line27.Layer = refin;//Layer指图层
            line27.LinetypeScale = 5 / scale * 1.5;
            line27.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line27);
            line28.Lineweight = Lineweight.W25;//Lineweight指线宽
            line28.Layer = refin;//Layer指图层
            line28.LinetypeScale = 5 / scale * 1.5;
            line28.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line28);
            line29.Lineweight = Lineweight.W25;//Lineweight指线宽
            line29.Layer = refin;//Layer指图层
            line29.LinetypeScale = 5 / scale * 1.5;
            line29.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line29);
            line29.Layer = refin;

            //标注
            double z1 = fun.CalDistance(p16, p10);
            double z2 = fun.CalDistance(p33, new Vector2(p34.X, p33.Y));
            Vector2 p58 = fun.Polar(p0, 0, lpr - lh);
            Vector2 p58_1 = fun.Polar(p58, pi + pi / 4, 1.7 * scale);
            Vector2 p58_2 = fun.Polar(p58_1, pi + pi / 4, dconms);
            Vector2 p58_3 = fun.Polar(p58_2, pi / -2, 1.2 * scale);
            Vector2 p59 = fun.Polar(p11, pi / 2, -p11.Y);
            Vector2 p65 = fun.Polar(fun.Polar(p40, 0, dconms), pi / -2, dconms * 2.0);
            Vector2 p66 = fun.Polar(p58, pi / 2, dconms / 2.0);
            Vector2 p67 = fun.Polar(p66, 115 * pi / 180, dconms / 2.0);
            Vector2 p68 = fun.Polar(p67, 115 * pi / 180, dconms / 2.0);
            Vector2 p69 = fun.Polar(p23, pi + pi / 4, 1.7 * scale); ;
            Vector2 p70 = fun.Polar(p69, pi + pi / 4, dconms);
            Vector2 p71 = fun.Polar(p70, pi / -2, 1.2 + 0.3);
            Vector2 p72 = fun.Polar(p22, pi + pi / 3, 1.7 * scale);
            Vector2 p73 = fun.Polar(p72, pi + pi / 3, dconms);
            Vector2 p74 = fun.Polar(p73, pi / -2, 1.2 + 0.3);
            Vector2 p75 = fun.Polar(p40, pi / 2, dconms / 2.0);
            Vector2 p76 = fun.Polar(p75, pi + pi / 4, 1.7 * scale);
            Vector2 p77 = fun.Polar(p76, pi + pi / 4, dconms);
            Vector2 p78 = fun.Polar(p77, pi / -2, 1.2 + 0.3);
            Vector2 p79 = fun.Polar(p23, pi, dc * 1.7);
            Vector2 p80 = fun.Polar(p79, pi / 2, dc * 2);
            Vector2 p81 = fun.Polar(p80, pi / 2, dconms / 2.0);
            Vector2 p82 = fun.Polar(p81, pi / 2, dconms / 2.0);
            Vector2 p83 = fun.Polar(p23, pi, dc * 3);
            Vector2 p84 = fun.Polar(p83, 0, dconms / 2.0);
            Vector2 p85 = fun.Polar(p84, 0, dconms / 2.0);
            Vector2 p86 = fun.Polar(p0, pi / 2, dc * 4.3);
            Vector2 p87 = fun.Polar(fun.Polar(p41, pi / 2, dc / 2.0 * scale * 1.5 + 3), pi, 1.2 * scale * 3);
            fun.dimrot1(dxf, p4, p22, 180, dc * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
            fun.dimrot1(dxf, fun.Polar(p6, 0, z1 / 2.0), p23, 0, dc * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "APMX", "", "");
            fun.dimrot1(dxf, p29, p22, 90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.dimrot1(dxf, p3, p4, -90, dc / 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "DN", "", "");
            fun.dimrot1(dxf, p40, p38, 180, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p35, p39, -90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, fun.Polar(p33, pi, z2 / 2.0), p23, 0, dc * 2.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LU", "", "");
            fun.dimrot1(dxf, p58, p23, 0, dc * 3.3, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR,LTA", "", "");
            fun.dimrot1(dxf, p36, p23, 0, dc * 3.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LF", "", "");
            fun.jdbz2(dxf, new Line(p25, p24), new Line(p23, fun.Polar(p23, pi / 2, 0.1)), dc, 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");
            fun.jdbz2(dxf, new Line(p59, fun.Polar(p59, pi, 0.1)), new Line(p11, fun.Polar(p11, pi + fha_, 0.1)), dc * 2.0, 1.2 * scale, 1.6 * scale, 0.9, "FHA", "", "");
            fun.Axis(dxf, p65, 0, -90, "Z", "X", "Y", 0.5 * scale, 1.2 * scale, 1);
            fun.Axis(dxf, fun.Polar(p40, pi / 2, dconms / 2.0), 180, -90, "", "", "", 0.5 * scale, 1.2 * scale, 11);
            fun.Axis(dxf, p58, 0, -90, "", "", "", 0.5 * scale, 1.2 * scale, 1);
            fun.Axis(dxf, p23, 0, -90, "", "", "", 0.5 * scale, 1.2 * scale, 1);
            fun.Singlelinearrow(dxf, "CCMS", p66, 115, p67, p68, 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "FDP", p82, 90, p81, p80, 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "A", p85, 0, p84, p83, 1.2 * scale, 1.6 * scale);
            Text txt = new Text("CIP", p71, 1.2 * scale, 0);
            dxf.AddEntity(txt);
            Text txt1 = new Text("CRP", p74, 1.2 * scale, 0);
            dxf.AddEntity(txt1);
            Text txt2 = new Text("PCS", p78, 1.2 * scale, 0);
            dxf.AddEntity(txt2);

            Text txt4 = new Text("VIEW A", p87, 1.2 * scale, 0);
            dxf.AddEntity(txt4);
            Text txt5 = new Text("MCS", p58_3, 1.2 * scale, 0);
            dxf.AddEntity(txt5);
            Line line30 = new Line(p69, p70);
            Line line31 = new Line(p72, p73);
            Line line32 = new Line(p76, p77);
            Line line40 = new Line(p58_1, p58_2);
            dxf.AddEntity(new EntityObject[] { line30, line31, line32, line40 });


            if (x == 0)
            {
                Text txt3 = new Text("ISYC=303-01", p86, 1.2 * scale, 0);
                dxf.AddEntity(txt3);
            }
            else
            {
                Text txt3 = new Text("ISYC=303-02", p86, 1.2 * scale, 0);
                dxf.AddEntity(txt3);
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ISYC_303_01and02(Dictionary<string, Object> data)  //整体非中心切削立铣刀
        {

            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //  double sl = Convert.ToDouble(data["oal"]);
            double sl = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);
            /*
            double sl = 84.5;
            double scale = 1;*/
            if (sl <= 50)
            {
                scale = 2.2;
            }
            else if (50 < sl && sl <= 75)
            {
                scale = 1.8;
            }
            else if (75 < sl && sl <= 100)
            {
                scale = 1.4;
            }
            else
            {
                scale = 1;
            }
            /*
             double pi = Math.PI;
             string path = Convert.ToString(data["path"]);
             double d = 10*scale ;           
             double lh = 48 * scale;
             double lu = 60.6 * scale;
             double oal = 84.5 * scale;
             double dconms = 12 * scale;
             double ls = 21.9 * scale;
             double dc = 11.5 * scale;
             double lpr = 63 * scale;
             double Z = 5-2;//齿数
             double a = 0.5 * scale;//倒角
             double fha = 30;
             double fha_ = fha * pi / 180;
             double kapr = 80;
             double kapr_ = kapr * pi / 180;
             */

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double d = Convert.ToDouble(data["dn"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double Z = Convert.ToDouble(data["zefp"]) - 1;//齿数
            double a = Convert.ToDouble(data["ec"]) * scale;//倒角
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double kapr = Convert.ToDouble(data["kapr"]);
            double kapr_ = kapr * pi / 180;
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_ = fun.Polar(p0, 0, oal + 5);
            Vector2 p0_1 = fun.Polar(p0, pi, oal - lh + 1);
            Vector2 p1 = fun.Polar(p0, 0.81120299, d * (0.14627067 / 1));
            Vector2 p1_ = fun.Polar(p1, 0, 500);
            Vector2 p2 = new Vector2(p0.X, -d * (0.16812936 / 1));
            Vector2 p4 = fun.Polar(p0, pi / -2, d / 2.0);

            Vector2 p3 = new Vector2(0, d / 2.0);
            Vector2 p3_ = fun.Polar(p3, pi / -2, 300);
            Vector2 p3_01 = fun.Polar(p3, 0, 300);
            Vector2 p3_02 = new Vector2((dc - d) / 2.0, dc / 2);
            Vector2 p4_ = fun.mirrorpoint(p3_02, p0_, p0_1);
            Vector2 p10_ = fun.Polar(p3, -fha_, 500);
            Vector2 p10 = fun.Inters(p3, p10_, p0, p0_);
            Arc arc3 = fun.DrawArc4(p10, 1.22 / 1 * d, p3, 0);
            Vector2 p6_ = fun.Polar(p1, 0, 500);
            Vector2 p6 = fun.Inters1(p6_, p1, arc3, 1);
            Vector2 p5 = fun.Polar(p6, pi, 0.13 / 1 * d);
            Vector2 p8 = fun.Polar(p4, -0.08002114, 0.70920754 / 1 * d);
            Vector2 p8_ = fun.Polar(p8, 0, 300);
            double v6_5 = fun.CalDistance(p6, p5);
            Vector2 p9 = fun.Polar(p10, pi, v6_5);
            Vector2 p9_ = fun.Polar(p9, -fha_, 300);
            Vector2 p12 = fun.Polar(p8, 0.09587523, 0.64141766 / 1.0 * d);
            Vector2 p13 = fun.Inters(p8, p8_, p9, p9_);
            Vector2 p13_ = fun.Polar(p13, 0.52141547, 300);
            Arc arc2 = fun.DrawArc4(p9, 1.79 / 1 * d, p13, 0);
            Vector2 p11_ = fun.Polar(p8, 0.53086055, 500);
            Vector2 p11 = fun.Inters1(p8, p11_, arc2, 0);
            Vector2 p16 = fun.Polar(p10, 0, 0.82792183 / 1 * d);//需修改
            Vector2 p16_ = fun.Polar(p16, -(fha - (30 - 28.1141772785456)) * pi / 180, 300); //需修改
                                                                                             // System.Diagnostics.Debug.WriteLine(-0.49068496*180/pi);
                                                                                             // System.Diagnostics.Debug.WriteLine(10000000001);
            double v8_13 = fun.CalDistance(p8, p13);
            Vector2 p15 = fun.Inters(p8, p8_, p16, p16_);
            Arc arc6 = fun.DrawArc4(p16, 1.46 / 1 * d, p15, 0);
            Vector2 p14 = fun.Inters1(p13, p13_, arc6, 0);
            Arc arc5 = fun.DrawArc4(p16, 1.46 / 1 * d, p3, 0);
            Arc arc7 = fun.DrawArc4(p1, 0.15788544 / 1.0 * d, p2, 0);
            Vector2 p17 = fun.Inters1(p3, p3_, arc7, 0);
            Vector2 p17_ = fun.Inters1(p3, p3_01, arc5, 1);
            double v1 = fun.CalDistance(p3, p17_);
            // System.Diagnostics.Debug.WriteLine(v1 );
            // System.Diagnostics.Debug.WriteLine(50003);
            double ang1 = fun.CalAngle(p3, p17_);
            double v2 = fun.CalDistance(p3, p10);
            double ang2 = fun.CalAngle(p3, p10);
            double v3 = fun.CalDistance(p10, p13);
            double v7 = fun.CalDistance(p10, p13);
            double ang3 = fun.CalAngle(p10, p13);
            double v4 = fun.CalDistance(p10, p16);
            double ang4 = fun.CalAngle(p10, p16);
            double v5 = fun.CalDistance(p13, p14);
            double ang5 = fun.CalAngle(p13, p14);
            double v6 = fun.CalDistance(p16, p15);
            double ang6 = fun.CalAngle(p16, p15);



            for (double i = v1; i < v1 * Z; i += v1)
            {



                Vector2 p1_1 = new Vector2(i, d / 2.0);//17

                Vector2 p2_1 = fun.Polar(p1_1, ang2, v2);

                Vector2 p3_1 = fun.Polar(p2_1, ang3, v3);
                Vector2 p3_2 = fun.Polar(p3_01, ang5, 300);
                Vector2 p4_1 = fun.Polar(p2_1, ang4, v4);
                Vector2 p6_1 = fun.Polar(p4_1, ang6, v6);

                Arc arc3_ = fun.DrawArc4(p4_1, 1.46 / 1 * d, p6_1, 0);
                Vector2 p5_1 = fun.Inters1(p3_1, p3_2, arc3_, 0);
                Arc arc1_ = fun.DrawArc4(p2_1, 1.22 / 1 * d, p1_1, 0);
                Arc arc2_ = fun.DrawArc4(p2_1, 1.79 / 1 * d, p3_1, 0);
                Line line1_ = new Line(p3_1, p5_1);
                Arc arc4_ = fun.DrawArc4(p4_1, 1.46 / 1 * d, p1_1, 0);
                // dxf.AddEntity(new EntityObject[] { arc1_,arc2_,arc3_ ,arc4_ ,line1_  });              

            }

            if (Z != 3)
            {
                //lh = Convert.ToDouble(data["lh"]) * scale + v1 * (Z - 3);
                lh = 48 * scale + v1 * (Z - 3);
            }


            Vector2 p20 = new Vector2(v1 * Z, d / 2.0);

            Vector2 p20_ = fun.Polar(p20, -fha_, 300);
            Vector2 p21 = fun.Inters(p20, p20_, p0, p0_);
            Arc arc10 = fun.DrawArc4(p21, 1.22 / 1 * d, p20, 0);
            Vector2 p22 = new Vector2(p4_.X + lh, -dc / 2.0);
            Arc arc11 = fun.DrawArc4(p21, 1.71 / 1 * d, p22, 0);
            Vector2 p23 = new Vector2(lh + (dc - d) / 2.0, 0);
            Vector2 p23_ = fun.Polar(p23, pi / 2 + (pi / 2 - kapr_), 300);
            Arc arc12 = fun.DrawArc4(p23, 1.46 / 1 * d, p20, 0);
            Vector2 p24 = fun.Polar(p20, 0, v1);
            Vector2 p24_ = fun.Polar(p22, 2.07007934, 1.18760651 / 1 * d);
            Vector2 p24_1 = fun.Polar(p24_, -(pi / 2 - kapr_), 300);
            Vector2 p25 = fun.Inters(p23, p23_, p24, p24_1);
            double ang10 = fun.CalAngle(p23, p25);
            double z1 = fun.CalDistance(p16, p10);
            double v10 = fun.CalDistance(p23, p25);
            Vector2 v20 = fun.Polar(p3_02, 0, z1 / 2.0);
            Vector2 v21 = fun.mirrorpoint(v20, p0_, p0_1);



            Arc arc16 = fun.DrawArc4(p23, 0.7157 / 1 * d, p22, 0);
            Vector2 p26 = fun.Polar(p23, ang10, 0.26 * d);
            Arc arc17 = fun.DrawArc4(p26, 1.22 / 1 * d, p24, 0);
            Arc arc8 = fun.DrawArc4(p2, 1.74026492 / 1.0 * d, p8, 0);
            Arc arc9 = fun.DrawArc4(p8, 2.21916736 / 1.0 * d, p4, 0);

            double v11 = fun.CalDistance(p26, p25);
            double ang11 = fun.CalAngle(p25, p24);
            double ang12 = fun.CalAngle(p25, p23);
            double ang13 = fun.CalAngle(p22, p23);
            double v13 = fun.CalDistance(p22, p23);
            Vector2 p27 = fun.Polar(p26, ang10, v11 / 2.0);
            Vector2 p27_ = fun.Polar(p27, pi / 4, 300);
            Vector2 p28 = fun.Inters(p27, p27_, p23, fun.Polar(p23, pi / 2, 300));
            Vector2 p29 = new Vector2(p3_02.X + lh, dc / 2.0);
            Vector2 v22 = fun.Polar(p29, pi / -2, dc / 4.0);
            Vector2 v23 = fun.Polar(p22, pi / 2, dc / 4.0);
            Vector2 p30 = fun.Polar(p25, ang11, 0.29365159 * d);
            Arc arc18 = fun.DrawArc4(p29, 0.79548631 / 1 * d, p30, 0);
            Vector2 p31 = fun.Polar(p22, ang13, v13 / 2.0);
            Vector2 p31_ = fun.Polar(p31, pi / -2 - (ang12 - ang11), 50);
            Vector2 p32 = fun.Inters1(p31, p31_, arc16, 0);
            Line line1 = new Line(p3, p3_02);
            Line line2 = new Line(p3_02, p29);
            Line line3 = new Line(p3, p4);
            Line line4 = new Line(p4, p4_);
            Line line5 = new Line(p4_, p22);
            Line line6 = new Line(p22, p29);
            Line line7 = new Line(p3_02, p4_);
            Line line8 = new Line(p29, v20);
            Line line9 = new Line(v21, p22);
            Line line10 = new Line(p29, v22);
            Line line11 = new Line(p22, v23);
            double v100 = fun.CalDistance(p22, p29);
            Vector2 p33 = fun.Polar(p3, pi, oal - ls - lh - (oal - lu - ls) * 2);
            Vector2 p33_ = fun.Polar(p33, pi - pi / 4, 50);
            Vector2 p33_1 = fun.Polar(p0, pi / 2, dconms / 2);
            Vector2 p33_2 = fun.Polar(p33_1, pi, 50);
            Vector2 p34 = fun.Inters(p33, p33_, p33_1, p33_2);
            Vector2 p35 = fun.Polar(p34, pi, ls - (a / Math.Sqrt(2)));
            Vector2 p36 = fun.Polar(p35, pi + pi / 4, a);
            Vector2 p37 = fun.mirrorpoint(p33, p0_, p0_1);
            Vector2 p38 = fun.mirrorpoint(p34, p0_, p0_1);
            Vector2 p39 = fun.mirrorpoint(p35, p0_, p0_1);
            Vector2 p40 = fun.mirrorpoint(p36, p0_, p0_1);
            Line line13 = new Line(p35, p36);
            Line line14 = new Line(p40, p39);
            Line line15 = new Line(p36, p40);
            Line line16 = new Line(p33, p3);
            Line line17 = new Line(p37, p4);
            //  dxf.AddEntity(new EntityObject[] { line1, line2, line3, line4,line5,line6,line7,line8,line9,line11,line12,line13,line14,line16,
            //  line17,line15,arc1 ,arc2 ,arc3 ,arc4 ,arc5 ,arc6 ,arc7,arc8,arc9,arc10,arc11,arc12,arc16,arc17,arc18});
            fun.drawBline(dxf, line1, 0.5, contour);
            fun.drawBline(dxf, line2, 0.5, contour);
            fun.drawBline(dxf, line3, 0.5, contour);
            fun.drawBline(dxf, line4, 0.5, contour);
            fun.drawBline(dxf, line5, 0.5, contour);
            fun.drawBline(dxf, line6, 0.5, contour);
            fun.drawBline(dxf, line7, 0.5, contour);
            fun.drawBline(dxf, line8, 0.8, contour);
            fun.drawBline(dxf, line9, 0.8, contour);
            fun.drawBline(dxf, line10, 0.8, contour);
            fun.drawBline(dxf, line11, 0.8, contour);
            fun.drawBline(dxf, line13, 0.5, contour);
            fun.drawBline(dxf, line14, 0.5, contour);
            fun.drawBline(dxf, line16, 0.5, contour);
            fun.drawBline(dxf, line15, 0.5, contour);
            fun.drawBline(dxf, line17, 0.5, contour);
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p35));
            poly1.Vertexes.Add(new LwPolylineVertex(p39));
            poly1.Vertexes.Add(new LwPolylineVertex(p38));
            poly1.Vertexes.Add(new LwPolylineVertex(p37));
            poly1.Vertexes.Add(new LwPolylineVertex(p33));
            poly1.Vertexes.Add(new LwPolylineVertex(p34));
            poly1.Vertexes.Add(new LwPolylineVertex(p38));
            poly1.Vertexes.Add(new LwPolylineVertex(p34));
            poly1.Vertexes.Add(new LwPolylineVertex(p35));
            //dxf.AddEntity(poly1);
            fun.PolyFill(dxf, poly1, 0.5, contour);
            Vector2 p41 = new Vector2(p23.X, p23.Y - 5 * dc);
            //标注

            double z2 = fun.CalDistance(p33, new Vector2(p34.X, p33.Y));
            Vector2 p58 = fun.Polar(p0, pi, lpr - lh);
            Vector2 p59 = fun.Polar(p11, pi / 2, -p11.Y);
            Vector2 p65 = fun.Polar(fun.Polar(p40, pi, dconms), pi / -2, dconms * 2.0);
            Vector2 p66 = fun.Polar(p58, pi / 2, dconms / 2.0);
            Vector2 p67 = fun.Polar(p66, 115 * pi / 180, dconms / 2.0);
            Vector2 p68 = fun.Polar(p67, 115 * pi / 180, dconms / 2.0);
            Vector2 p69 = fun.Polar(p23, pi + pi / 4, 1.7 * scale); ;
            Vector2 p70 = fun.Polar(p69, pi + pi / 4, dconms);
            Vector2 p71 = fun.Polar(p70, pi / -2, 1.2 + 0.3);
            Vector2 p72 = fun.Polar(p22, pi + pi / 3, 1.7 * scale);
            Vector2 p73 = fun.Polar(p72, pi + pi / 3, dconms);
            Vector2 p74 = fun.Polar(p73, pi / -2, 1.2 + 0.3);
            Vector2 p75 = fun.Polar(p40, pi / 2, dconms / 2.0);
            Vector2 p76 = fun.Polar(p75, pi + pi / 4, 1.7 * scale);
            Vector2 p77 = fun.Polar(p76, pi + pi / 4, dconms);
            Vector2 p78 = fun.Polar(p77, pi / -2, 1.2 + 0.3);
            Vector2 p79 = fun.Polar(p23, 0, dc * 1.7);
            Vector2 p80 = fun.Polar(p79, pi / 2, dc * 2);
            Vector2 p81 = fun.Polar(p80, pi / 2, dconms / 2.0);
            Vector2 p82 = fun.Polar(p81, pi / 2, dconms / 2.0);
            Vector2 p83 = fun.Polar(p23, 0, dc * 3);
            Vector2 p84 = fun.Polar(p83, 0, dconms / 2.0);
            Vector2 p85 = fun.Polar(p84, 0, dconms / 2.0);
            Vector2 p86 = fun.Polar(p0, pi / 2, dc * 4.3);
            Vector2 p87 = fun.Polar(fun.Polar(p41, pi / 2, dc / 2.0 * scale * 1.5 + 3), pi, 1.2 * scale * 3);



            Ellipse ellipse01 = new Ellipse(p22, dc - 3, 5.3388 / 16.1 * (dc) * scale * 1.5);//椭圆
            ellipse01.Rotation = 90;
            ellipse01.Layer = contour;
            ellipse01.Lineweight = Lineweight.W50;
            dxf.AddEntity(ellipse01);

            Text txt = new Text("X", fun.Polar(p22, pi - 4, dc), 2.2 * scale, 0);
            dxf.AddEntity(txt);

            fun.dimrot1(dxf, p4, p22, 180, dc * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
            fun.dimrot1(dxf, v21, p23, 180, dc * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "APMX", "", "");
            fun.dimrot1(dxf, p29, p22, -90, dc * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.dimrot1(dxf, p3, p4, 90, dc / 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "DN", "", "");
            fun.dimrot1(dxf, p40, p38, 180, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p35, p39, 90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p58, p23, 0, dc * 3.3, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR", "", "");
            fun.dimrot1(dxf, p36, p23, 0, dc * 3.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }





        public static void Integral5shapedendmill(Dictionary<string, Object> data)  //整体V型立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //  double sl = Convert.ToDouble(data["oal"]);
            double sl = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);
            /*
            double sl = 84.5;
            double scale = 2;*/
            if (sl <= 50)
            {
                scale = 2.2;
            }
            else if (50 < sl && sl <= 75)
            {
                scale = 1.8;
            }
            else if (75 < sl && sl <= 100)
            {
                scale = 1.4;
            }
            else
            {
                scale = 1;
            }
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double bd = Convert.ToDouble(data["bd"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double xb = (Math.Sqrt((((bd - dc) / 2.0) * ((bd - dc) / 2.0) + (lh * lh))));
            double kapr = Convert.ToDouble(data["kapr"]) * scale;
            double kapr_ = kapr * pi / 180;
            if (kapr_ == 0)
            {
                kapr_ = Math.Asin(lh / xb);
            }
            /*
            double scale = 2;
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double dc =5*scale ;
            double bd = 20 * scale;
            double lh = 8 * scale;
            double oal = 41*scale ;
            double ls = 32*scale ;
            double dconms = 10 * scale;
            double xb = (Math.Sqrt((((bd - dc) / 2.0) * ((bd - dc) / 2.0) + (lh * lh))));
            //double kapr = Math.Asin(lh / xb);
            double kapr_ = Math.Asin(lh / xb);*/
            // double kapr_ = kapr * pi / 180;
            /*System.Diagnostics.Debug.WriteLine(kapr *180/pi);
            System.Diagnostics.Debug.WriteLine(50002);
            */
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = new Vector2(5, 0);
            Vector2 p0_2 = new Vector2(-100, 0);
            Vector2 p0_3 = new Vector2(-5, 0);
            Vector2 p0_4 = new Vector2(oal + 5, 0);
            Vector2 p1 = fun.Polar(p0, pi / 2, dc / 2.0);
            Vector2 p2 = fun.Polar(p0, pi / -2, dc / 2.0);
            Vector2 p3 = fun.Polar(p2, -pi / 2 + kapr_, 15.41389957 / 18.00631226 * xb);
            Vector2 p4 = fun.Polar(p2, -pi / 2 + kapr_, xb);
            Vector2 p9 = fun.Polar(p4, pi / 2, bd);
            Vector2 p10 = fun.mirrorpoint(p3, p0_1, p0_2);
            Vector2 p11 = fun.Inters(p10, p3, p0_1, p0_2);
            Vector2 p12 = fun.Polar(p1, pi / -2, dc / 20);
            Vector2 p13 = fun.Polar(p10, pi / -2, bd / 20);
            Vector2 p14 = fun.mirrorpoint(p12, p0_1, p0_2);
            Vector2 p15 = fun.mirrorpoint(p13, p0_1, p0_2);
            Vector2 p16 = fun.Polar(p12, pi / -2, (p12.Y - p0.Y) / 2.0);
            Vector2 p17 = fun.Polar(p13, pi / -2, (p13.Y - p11.Y) / 2.0);
            Vector2 p18 = fun.mirrorpoint(p16, p0_1, p0_2);
            Vector2 p19 = fun.mirrorpoint(p17, p0_1, p0_2);
            Vector2 p20 = fun.Polar(p12, pi / -2, (p12.Y - p16.Y) / 2.0);
            Vector2 p20_ = fun.Polar(p13, pi / -2, (p13.Y - p17.Y) / 2.0);
            double ang1 = fun.CalAngle(p20, p20_);
            Vector2 p22 = fun.Polar(p13, pi / -2, (p13.Y - p17.Y) / 3.0);
            Vector2 p22_ = fun.Polar(p22, pi + pi / 3, 100);
            Vector2 p21 = fun.Inters(p20, p20_, p22, p22_);
            Vector2 p23 = fun.mirrorpoint(p20, p0_1, p0_2);
            Vector2 p24 = fun.mirrorpoint(p21, p0_1, p0_2);
            Vector2 p25 = fun.mirrorpoint(p22, p0_1, p0_2);
            Vector2 p26 = fun.Polar(p16, pi / -2, (p16.Y - p0.Y) / 2.0);
            Vector2 p26_ = fun.Polar(p17, pi / -2, (p17.Y - p11.Y) / 2.0);
            Vector2 p28 = fun.Polar(p17, pi / -2, (p17.Y - p11.Y) / 5.0);
            Vector2 p28_ = fun.Polar(p28, pi + 50 * pi / 180, 100);
            Vector2 p27 = fun.Inters(p28, p28_, p26, p26_);
            Vector2 p29 = fun.mirrorpoint(p26, p0_1, p0_2);
            Vector2 p30 = fun.mirrorpoint(p27, p0_1, p0_2);
            Vector2 p31 = fun.mirrorpoint(p28, p0_1, p0_2);
            Vector2 p32 = new Vector2(oal, 0);
            Vector2 p33 = fun.Polar(p32, pi / 2, dconms / 2.0 - 0.5 * scale);
            Vector2 p34 = fun.Polar(p33, pi / 2 + pi / 4, Math.Sqrt(2) * 0.5 * scale);
            Vector2 p35 = fun.Polar(p34, pi, ls + (p34.X - p33.X));
            Vector2 p36 = fun.Polar(p35, pi - pi / 4, Math.Sqrt(2) * scale);
            Vector2 p37 = fun.mirrorpoint(p33, p0_1, p0_2);
            Vector2 p38 = fun.mirrorpoint(p34, p0_1, p0_2);
            Vector2 p39 = fun.mirrorpoint(p35, p0_1, p0_2);
            Vector2 p40 = fun.mirrorpoint(p36, p0_1, p0_2);
            //System.Diagnostics.Debug.WriteLine(Math .Sqrt ((((bd-dc)/2.0)* ((bd - dc) / 2.0)+(lh*lh))));

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p11));
            poly1.Vertexes.Add(new LwPolylineVertex(p0));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p10));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            fun.PolyFill(dxf, poly1, 0.5, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes.Add(new LwPolylineVertex(p17));
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            poly2.Vertexes.Add(new LwPolylineVertex(p14));
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes.Add(new LwPolylineVertex(p19));
            poly2.Vertexes.Add(new LwPolylineVertex(p18));
            fun.PolyFill(dxf, poly2, 0.5, contour);
            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p34));
            poly3.Vertexes.Add(new LwPolylineVertex(p38));
            poly3.Vertexes.Add(new LwPolylineVertex(p37));
            poly3.Vertexes.Add(new LwPolylineVertex(p33));
            poly3.Vertexes.Add(new LwPolylineVertex(p34));
            poly3.Vertexes.Add(new LwPolylineVertex(p35));
            poly3.Vertexes.Add(new LwPolylineVertex(p39));
            poly3.Vertexes.Add(new LwPolylineVertex(p40));
            poly3.Vertexes.Add(new LwPolylineVertex(p36));
            poly3.Vertexes.Add(new LwPolylineVertex(p35));
            poly3.Vertexes.Add(new LwPolylineVertex(p39));
            poly3.Vertexes.Add(new LwPolylineVertex(p38));
            fun.PolyFill(dxf, poly3, 0.5, contour);
            Line line1 = new Line(p20, p21);
            fun.drawBline(dxf, line1, 0.5, contour);
            Line line2 = new Line(p23, p24);
            fun.drawBline(dxf, line2, 0.5, contour);
            Line line3 = new Line(p26, p27);
            fun.drawBline(dxf, line3, 0.5, contour);
            Line line4 = new Line(p29, p30);
            fun.drawBline(dxf, line4, 0.5, contour);
            Arc arc1 = fun.DrawArc4(p21, 1.64 * scale, p22, 0);
            fun.drawBArc(dxf, arc1, 0.5, contour);
            Arc arc2 = fun.DrawArc4(p25, 1.64 * scale, p24, 0);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            Arc arc3 = fun.DrawArc4(p27, 1.64 * scale, p28, 0);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            Arc arc4 = fun.DrawArc4(p31, 1.64 * scale, p30, 0);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            // dxf.AddEntity(new EntityObject[] { arc1,arc2,arc3 ,arc4  ,poly1 ,poly2,poly3 ,line1 ,line2,line3,line4  });

            //标注
            double j1 = fun.CalDistance(p2, p3);
            Vector2 b1 = fun.Polar(p2, pi / -2 + kapr_, j1 / 5 * 4);
            Vector2 b2 = fun.Polar(p1, pi / 2 - kapr_, j1 / 5 * 4);
            Vector2 b3 = fun.Polar(p2, pi / -2 + kapr_, j1 / 6 * 5);
            Vector2 b4 = fun.Polar(p1, pi / 2 - kapr_, j1 / 6 * 4);
            Vector2 b5 = fun.Polar(p1, pi / 2 - kapr_, 0.1);
            Vector2 b6 = fun.Polar(p1, pi / 2, 0.1);
            Vector2 b7 = fun.Polar(p0, 0, oal / 2.0);
            Vector2 b8 = fun.Polar(b7, pi / 2, dconms);
            Vector2 b9 = fun.Polar(b8, pi / 4, dconms / 5.0);
            Vector2 b10 = fun.Polar(b9, 0, dconms / 5.0);
            Vector2 b11 = fun.mirrorpoint(b8, p0_1, p0_2);
            Vector2 b12 = fun.mirrorpoint(b9, p0_1, p0_2);
            Vector2 b13 = fun.mirrorpoint(b10, p0_1, p0_2);
            Vector2 b14 = fun.Polar(p32, -pi / 3, bd);
            Vector2 b15_ = fun.Polar(p2, -pi / 2 - 15 * pi / 180, 1.7 * 0.4);
            Vector2 b15_1 = fun.Polar(b15_, -pi / 2 - 25 * pi / 180, dc * 2);
            Vector2 b15_2 = fun.Polar(b15_1, pi / -2, 1.2 * scale);
            Vector2 b16_ = fun.Polar(p0, -pi / 2 - pi / 4, 1.7 * 0.4);
            Vector2 b16_1 = fun.Polar(b16_, -pi / 2 - pi / 4, bd);
            Vector2 b16_2 = fun.Polar(b16_1, pi / -2, 1.2 * scale);
            Vector2 b17_ = fun.Polar(b7, 0, ls / 6);
            Vector2 b17 = fun.Polar(b17_, pi / 2, dconms / 2.0);
            Vector2 b18 = fun.Polar(b17, 75 * pi / 180, dconms / 2.0);
            Vector2 b19 = fun.Polar(b18, 75 * pi / 180, dconms / 2.0);
            Vector2 b20 = fun.Polar(b7, -pi / 4, 1.7 * scale);
            Vector2 b21 = fun.Polar(b20, -pi / 4, dconms);
            Vector2 b22 = fun.Polar(b21, pi / -2, 1.2 * scale);
            Vector2 b23 = fun.Polar(p32, -pi / 3, 1.7 * 0.4);
            Vector2 b24 = fun.Polar(b23, -pi / 3, dconms);
            Vector2 b25 = fun.Polar(b24, pi / -2, 1.2 * scale);
            Vector2 b26 = fun.Polar(b7, pi / 2, dc * 5.5);
            fun.dimrot1(dxf, p4, p2, 180, dc * 2.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
            fun.dimrot1(dxf, b1, p2, 180, dc * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "APMX", "", "");
            fun.dimrot1(dxf, p1, p2, 90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.dimrot1(dxf, b3, b4, 90, dc * 2.2 + 1.2 * scale * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCX", "", "");
            fun.dimrot1(dxf, p4, p9, 90, dc * 3.2 + 1.2 * scale * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "BD", "", "");
            fun.dimrot1(dxf, p39, p37, 180, dc * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p38, p34, 90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p1, p33, 0, dc * 4, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LF", "", "");
            fun.dimrot1(dxf, b7, p0, 0, dc * 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR,LTA", "", "");

            fun.jdbz2(dxf, new Line(p1, b5), new Line(p1, b6), dc * 2, 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");

            fun.Axis(dxf, b14, 0, -90, "Z", "X", "Y", 0.4, 1.2 * scale, 1);
            fun.Axis(dxf, p0, 0, -90, "", "", "", 0.4, 1.2 * scale, 1);
            fun.Axis(dxf, b7, 0, -90, "", "", "", 0.4, 1.2 * scale, 1);
            fun.Axis(dxf, p32, 0, -90, "", "", "", 0.4, 1.2 * scale, 1);
            Line line5 = new Line(b8, b11);
            line5.Lineweight = Lineweight.W35;//Lineweight指线宽
            line5.Layer = additionalline;//Layer指图层
            line5.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line5.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line5); //提取
            Line line6 = new Line(b8, b9);
            line6.Lineweight = Lineweight.W35;//Lineweight指线宽
            line6.Layer = additionalline;//Layer指图层
            line6.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line6.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line6); //提取
            Line line7 = new Line(b9, b10);
            line7.Lineweight = Lineweight.W35;//Lineweight指线宽
            line7.Layer = additionalline;//Layer指图层
            line7.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line7.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line7); //提取
            Line line8 = new Line(b12, b11);
            line8.Lineweight = Lineweight.W35;//Lineweight指线宽
            line8.Layer = additionalline;//Layer指图层
            line8.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line8.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line8); //提取
            Line line9 = new Line(b12, b13);
            line9.Lineweight = Lineweight.W35;//Lineweight指线宽
            line9.Layer = additionalline;//Layer指图层
            line9.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line9.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line9); //提取

            Line line10 = new Line(b15_, b15_1);
            Line line11 = new Line(b16_, b16_1);
            Line line12 = new Line(b20, b21);
            Line line13 = new Line(b23, b24);
            dxf.AddEntity(line10);
            dxf.AddEntity(line11);
            dxf.AddEntity(line12);
            dxf.AddEntity(line13);
            Text txt1 = new Text("CRP", b15_2, 1.2 * scale, 0);
            dxf.AddEntity(txt1);
            Text txt2 = new Text("CIP", b16_2, 1.2 * scale, 0);
            dxf.AddEntity(txt2);
            Text txt3 = new Text("MCS", b22, 1.2 * scale, 0);
            dxf.AddEntity(txt3);
            Text txt4 = new Text("PCS", b25, 1.2 * scale, 0);
            dxf.AddEntity(txt4);
            Text txt5 = new Text("ISYC=303_03", b26, 1.2 * scale, 0);
            dxf.AddEntity(txt5);
            fun.Singlelinearrow(dxf, "CCMS", b17, 75, b18, b19, 1.2 * scale, 1.6 * scale);

            Line line14 = new Line(p0_3, p0_4);
            line14.Lineweight = Lineweight.W25;//Lineweight指线宽
            line14.Layer = center;//Layer指图层
            line14.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line14.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line14); //提取


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ISYC_303_03(Dictionary<string, Object> data)  //整体V型立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //  double sl = Convert.ToDouble(data["oal"]);
            double sl = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);
            if (sl <= 50)
            {
                scale = 2.2;
            }
            else if (50 < sl && sl <= 75)
            {
                scale = 1.8;
            }
            else if (75 < sl && sl <= 100)
            {
                scale = 1.4;
            }
            else
            {
                scale = 1;
            }

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcx = Convert.ToDouble(data["dcx"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double xb = (Math.Sqrt((((dcx - dc) / 2.0) * ((dcx - dc) / 2.0) + (apmx * apmx))));
            double kapr = Convert.ToDouble(data["kapr"]) * scale;
            double kapr_ = kapr * pi / 180;
            if (kapr_ == 0)
            {
                kapr_ = Math.Asin(apmx / xb);
            }

            /*
            double scale = 2;
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double dc = 5 * scale;
            double dcx = 20 * scale;
            double oal = 50 * scale;
            double lpr = 35 * scale;
            double ls = 32 * scale;
            double dconms = 5 * scale;
            double dn = 4 * scale;
            double apmx = 16 * scale;
            double xb = (Math.Sqrt((((dcx - dc) / 2.0) * ((dcx - dc) / 2.0) + (apmx * apmx))));
            //double kapr = Math.Asin(lh / xb);
            double kapr_ = Math.Asin(apmx / xb);
            // double kapr_ = kapr * pi / 180;
            /*System.Diagnostics.Debug.WriteLine(kapr *180/pi);
            System.Diagnostics.Debug.WriteLine(50002);
            *//*
            if (kapr_ == 0)
            {
                kapr_ = Math.Asin(apmx / xb);
            }*/
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = new Vector2(-5, 0);
            Vector2 p0_2 = new Vector2(oal + 5, 0);
            Vector2 p1 = fun.Polar(p0, pi / 2, dc / 2.0);
            Vector2 p2 = fun.Polar(p0, pi / -2, dc / 2.0);
            Vector2 p3 = fun.Polar(p1, pi / 2 - kapr_, xb);
            Vector2 p4 = fun.mirrorpoint(p3, p0_1, p0_2);
            Vector2 p5 = fun.Polar(p3, pi / -2, dcx / 2.0);
            Vector2 p5_1 = fun.Polar(p5, pi / 2, dn / 2.0);
            Vector2 p5_ = fun.Polar(p5_1, 0, 100);
            Vector2 p6 = fun.Polar(p5, pi / 2, dconms / 2.0);
            Vector2 p6_ = fun.Polar(p6, pi / -4, 100);
            Vector2 p7 = fun.Inters(p6, p6_, p5_1, p5_);
            Vector2 p7_ = fun.Polar(p7, 0, 100);
            Vector2 p8 = fun.Polar(p6, 0, oal - (ls + apmx));
            Vector2 p8_ = fun.Polar(p8, pi / -2 - pi / 4, 100);
            Vector2 p9 = fun.Inters(p8, p8_, p7, p7_);
            Vector2 p10 = fun.Polar(p8, 0, ls - 0.5 * scale);
            Vector2 p11 = fun.Polar(p10, pi / -4, Math.Sqrt(2) * 0.5 * scale);
            Vector2 p12 = fun.mirrorpoint(p6, p0_1, p0_2);
            Vector2 p13 = fun.mirrorpoint(p7, p0_1, p0_2);
            Vector2 p14 = fun.mirrorpoint(p8, p0_1, p0_2);
            Vector2 p15 = fun.mirrorpoint(p9, p0_1, p0_2);
            Vector2 p16 = fun.mirrorpoint(p10, p0_1, p0_2);
            Vector2 p17 = fun.mirrorpoint(p11, p0_1, p0_2);
            Vector2 p18 = fun.Polar(p1, pi / -2, dc / 5);
            Vector2 p19 = fun.Polar(p2, pi / 2, dc / 5);
            Vector2 b7 = fun.Polar(p0, 0, lpr);
            Vector2 b8 = fun.Polar(b7, pi / 2, dconms);
            Vector2 b9 = fun.Polar(b8, pi / 4, dconms / 5.0);
            Vector2 b10 = fun.Polar(b9, 0, dconms / 5.0);
            Vector2 b11 = fun.mirrorpoint(b8, p0_1, p0_2);
            Vector2 b12 = fun.mirrorpoint(b9, p0_1, p0_2);
            Vector2 b13 = fun.mirrorpoint(b10, p0_1, p0_2);
            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            fun.PolyFill(dxf, poly1, 0.5, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p6));
            poly2.Vertexes.Add(new LwPolylineVertex(p7));
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            poly2.Vertexes.Add(new LwPolylineVertex(p10));
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p17));
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes.Add(new LwPolylineVertex(p14));
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            fun.PolyFill(dxf, poly2, 0.5, contour);

            Line line1 = new Line(p7, p13);
            Line line2 = new Line(p9, p15);
            Line line3 = new Line(p8, p14);
            Line line4 = new Line(p10, p16);
            Line line5 = new Line(p3, p1);
            Line line6 = new Line(p18, p1);
            Line line7 = new Line(p19, p2);
            Line line8 = new Line(p4, p2);
            fun.drawBline(dxf, line1, 0.5, contour);
            fun.drawBline(dxf, line2, 0.5, contour);
            fun.drawBline(dxf, line3, 0.5, contour);
            fun.drawBline(dxf, line4, 0.5, contour);
            fun.drawBline(dxf, line5, 1, contour);
            fun.drawBline(dxf, line6, 1, contour);
            fun.drawBline(dxf, line7, 1, contour);
            fun.drawBline(dxf, line8, 1, contour);
            // dxf.AddEntity(new EntityObject[] { poly1, poly2,line1,line2,line3,line4 });
            Line line9 = new Line(b8, b11);
            line9.Lineweight = Lineweight.W35;//Lineweight指线宽
            line9.Layer = additionalline;//Layer指图层
            line9.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line9.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line9); //提取
            Line line10 = new Line(b8, b9);
            line10.Lineweight = Lineweight.W35;//Lineweight指线宽
            line10.Layer = additionalline;//Layer指图层
            line10.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line10.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line10); //提取
            Line line11 = new Line(b9, b10);
            line11.Lineweight = Lineweight.W35;//Lineweight指线宽
            line11.Layer = additionalline;//Layer指图层
            line11.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line11.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line11); //提取
            Line line12 = new Line(b12, b11);
            line12.Lineweight = Lineweight.W35;//Lineweight指线宽
            line12.Layer = additionalline;//Layer指图层
            line12.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line12.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line12); //提取
            Line line13 = new Line(b12, b13);
            line13.Lineweight = Lineweight.W35;//Lineweight指线宽
            line13.Layer = additionalline;//Layer指图层
            line13.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line13.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line13); //提取
            Line line14 = new Line(p0_1, p0_2);
            line14.Lineweight = Lineweight.W25;//Lineweight指线宽
            line14.Layer = center;//Layer指图层
            line14.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line14.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
            dxf.AddEntity(line14); //提取
            //标注
            fun.dimrot1(dxf, p1, p3, 0, dc * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "APMX", "", "");
            fun.dimrot1(dxf, p4, p3, 90, dc * 5, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCX", "", "");
            fun.dimrot1(dxf, p1, p2, 90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.dimrot1(dxf, p8, p11, 0, dc * 2.8, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p10, p16, -90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, b7, p2, 180, dc * 5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR", "", "");
            fun.dimrot1(dxf, p2, p17, 180, dc * 5.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p7, p13, -90, dc, 2, 1.2 * scale, 1.6 * scale, 0.9, "DN", "", "");
            fun.jdbz2(dxf, new Line(p2, fun.Polar(p2, pi / -2, 0.1)), new Line(p2, p4), dc * 2.5, 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Concavesemicircularendmill(Dictionary<string, Object> data)  //整体凹半圆形轮廓立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*                                                       //  double sl = Convert.ToDouble(data["oal"]);
    double sl = Convert.ToDouble(data["oal"]);
    double scale = Convert.ToDouble(data["scale"]);
     */
            double sl = 68;
            double scale = 1;

            if (sl <= 67)
            {
                scale = 2.2;
            }
            else if (67 < sl && sl <= 75)
            {
                scale = 1.8;
            }
            else if (75 < sl && sl <= 100)
            {
                scale = 1.4;
            }
            else
            {
                scale = 1;
            }

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double oal = 67 * scale;
            double ls = 35 * scale;
            double apmx = 4.71 * scale;
            double dconms = 14 * scale;
            double dc = 7 * scale;
            double dn = 7 * scale;
            double lpr = 40 * scale;
            double dcx = 14 * scale;
            double fha = 20;
            double fha_ = fha * pi / 180;
            // double prfrad = 7.777778*scale   ;
            double prfrad = 14;

            System.Diagnostics.Debug.WriteLine(1.9 / scale);
            System.Diagnostics.Debug.WriteLine(5588895);
            /*
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dn = Convert.ToDouble(data["dc"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double dcx = Convert.ToDouble(data["dcx"]) * scale;
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double prfrad = Convert.ToDouble(data["prfrad"]);
            */
            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = new Vector2(-5, 0);
            Vector2 p0_2 = new Vector2(oal + 5, 0);
            Vector2 p1 = fun.Polar(p0, pi / 2, dc / 2.0);
            Vector2 p2 = fun.mirrorpoint(p1, p0_1, p0_2);
            Vector2 p3 = new Vector2(apmx, dcx / 2.0);
            Vector2 p4 = fun.mirrorpoint(p3, p0_1, p0_2);
            Vector2 p5 = fun.Polar(p3, 0, ((oal - sl - apmx) - 1 * scale - 1 * scale) / 2.0);
            Vector2 p6 = fun.mirrorpoint(p5, p0_1, p0_2);
            Vector2 p7 = fun.Polar(p5, pi / -4, Math.Sqrt(2) * 1 * scale);
            Vector2 p8 = fun.mirrorpoint(p7, p0_1, p0_2);
            Vector2 p9 = fun.Polar(p0, -15 * pi / 180, 100);
            Vector2 p10_1 = new Vector2(38.3817 / 58.881 * (fun.CalDistance(p3, p5)) + apmx, -dcx / 2.0);
            Vector2 p10_2 = fun.Polar(p10_1, pi / 2, 100);
            Vector2 p11 = fun.Polar(p2, fha_ - 20 * pi / 180, 100);
            Vector2 p12 = fun.Inters(p2, p11, p10_1, p10_2);
            Vector2 p13 = fun.Inters(p2, p11, p3, p4);
            Vector2 p14 = fun.Polar(p2, pi / 2, fun.CalDistance(p2, p0) / 2.0);
            Vector2 p15 = fun.Polar(p4, fun.CalAngle(p4, p2), fun.CalDistance(p4, p2) / 2.0);
            Vector2 p16 = fun.Polar(p15, fun.CalAngle(p4, p2) - pi / 2, 100);
            Arc arc2 = fun.DrawArc4(p4, prfrad, p2, 0);
            Arc arc3 = fun.DrawArc4(p13, 14 * scale, p14, 0);
            Vector2 p17 = fun.Inters1(p15, p16, arc2, 1);
            Vector2 p18 = fun.Polar(p13, fun.CalAngle(p13, p14), fun.CalDistance(p13, p14) / 2.0);
            Vector2 p19 = fun.Polar(p18, fun.CalAngle(p13, p14) - pi / 2, 100);
            Vector2 p20 = fun.Inters1(p18, p19, arc3, 1);
            Vector2 p21 = fun.Polar(p0, -6 * pi / 180, 100);
            Vector2 p22 = fun.Inters(p0, p21, p4, p3);
            Vector2 p23 = fun.Polar(p22, -fha_, 100);
            Vector2 p24 = fun.Inters(p22, p23, p10_1, p10_2);
            Vector2 p26 = fun.Polar(p24, pi / 2, dcx / 2.0);
            Vector2 p27 = fun.Polar(p12, pi / 2, dcx / 2.0);
            Vector2 p28 = fun.Polar(p1, pi / -2, fun.CalDistance(p1, p0) / 2.0);
            Vector2 p29 = fun.Polar(p3, pi / -2, fun.CalDistance(p1, p0) / 2.0);
            Vector2 p30 = fun.Polar(p28, pi / -2, fun.CalDistance(p28, p0) / 2.0);
            Vector2 p30_ = fun.Polar(p30, 0.34710403, 100);
            Vector2 p31 = fun.Inters(p30, p30_, p4, p3);
            Arc arc1 = fun.DrawArc4(p1, prfrad, p3, 0);
            Arc arc9 = fun.DrawArc4(p28, prfrad, p29, 0);
            Vector2 p32_ = fun.Polar(p17, pi / 2, 100);
            Vector2 p33_ = fun.Polar(p20, pi / 2 + 5 * pi / 180, 100);
            //Vector2 p33_ = new Vector2(p20.X, 100);
            Vector2 p32 = fun.Inters1(p17, p32_, arc1, 1);
            Vector2 p33 = fun.Inters1(p33_, p20, arc9, 1);

            Vector2 p34 = fun.Polar(p7, 0, ((oal - sl - apmx) - 1 * scale - 1 * scale) / 2.0);
            Vector2 p35 = fun.Polar(p34, pi / 4, Math.Sqrt(2) * 1 * scale);
            Vector2 p36 = fun.Polar(p35, 0, ls - 0.5 * scale);
            Vector2 p37 = fun.Polar(p36, pi / -4, Math.Sqrt(2) * 0.5 * scale);
            Vector2 p38 = fun.mirrorpoint(p34, p0_1, p0_2);
            Vector2 p39 = fun.mirrorpoint(p35, p0_1, p0_2);
            Vector2 p40 = fun.mirrorpoint(p36, p0_1, p0_2);
            Vector2 p41 = fun.mirrorpoint(p37, p0_1, p0_2);
            Vector2 p42 = fun.Polar(p0, 0, lpr);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            fun.PolyFill(dxf, poly1, 0.5, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p35));
            poly2.Vertexes.Add(new LwPolylineVertex(p34));
            poly2.Vertexes.Add(new LwPolylineVertex(p38));
            poly2.Vertexes.Add(new LwPolylineVertex(p39));
            poly2.Vertexes.Add(new LwPolylineVertex(p35));
            poly2.Vertexes.Add(new LwPolylineVertex(p36));
            poly2.Vertexes.Add(new LwPolylineVertex(p37));
            poly2.Vertexes.Add(new LwPolylineVertex(p41));
            poly2.Vertexes.Add(new LwPolylineVertex(p40));
            poly2.Vertexes.Add(new LwPolylineVertex(p36));
            poly2.Vertexes.Add(new LwPolylineVertex(p40));
            poly2.Vertexes.Add(new LwPolylineVertex(p39));
            fun.PolyFill(dxf, poly2, 0.5, contour);
            Line line1 = new Line(p1, p2);
            Line line2 = new Line(p13, p12);
            Line line3 = new Line(p22, p24);
            Line line4 = new Line(p29, p26);
            Line line5 = new Line(p27, p31);
            Line line6 = new Line(p7, p34);
            Line line7 = new Line(p8, p38);
            fun.drawBline(dxf, line1, 0.5, contour);
            fun.drawBline(dxf, line2, 0.5, contour);
            fun.drawBline(dxf, line3, 0.5, contour);
            fun.drawBline(dxf, line4, 0.5, contour);
            fun.drawBline(dxf, line5, 0.5, contour);
            fun.drawBline(dxf, line6, 0.5, contour);
            fun.drawBline(dxf, line7, 0.5, contour);
            Arc arc4 = fun.DrawArc4(p4, 10 * scale, p13, 0);
            Arc arc5 = fun.DrawArc4(p17, 14 * scale, p20, 0);
            Arc arc6 = fun.DrawArc4(p22, 48 * scale, p0, 0);
            Arc arc7 = fun.DrawArc4(p12, 1.05556 * scale, p24, 0);
            Arc arc8 = fun.DrawArc4(p27, 1.05556 * scale, p26, 0);
            Arc arc10 = fun.DrawArc4(p30, 19.50675846 / 2.0 * scale, p31, 0);
            Arc arc11 = fun.DrawArc4(p29, 5.98423777 / 2.0 * scale, p3, 0);
            Arc arc12 = fun.DrawArc4(p33, 14 * scale, p32, 0);
            Arc arc13 = fun.DrawArc4(p22, 7.3741868 * scale, p31, 0);
            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            fun.drawBArc(dxf, arc3, 0.5, contour);
            fun.drawBArc(dxf, arc4, 0.5, contour);
            fun.drawBArc(dxf, arc5, 0.5, contour);
            fun.drawBArc(dxf, arc6, 0.5, contour);
            fun.drawBArc(dxf, arc7, 0.5, contour);
            fun.drawBArc(dxf, arc8, 0.5, contour);
            fun.drawBArc(dxf, arc9, 0.5, contour);
            fun.drawBArc(dxf, arc10, 0.5, contour);
            fun.drawBArc(dxf, arc11, 0.5, contour);
            fun.drawBArc(dxf, arc12, 0.5, contour);
            fun.drawBArc(dxf, arc13, 0.5, contour);
            //标注
            Vector2 v1 = fun.Polar(p35, 0, fun.CalDistance(p35, p36) / 2.0 + 3);
            Vector2 v2 = fun.Polar(p32, pi / 2 + pi / 4, dcx / 2.0);
            Vector2 v3 = fun.Polar(p0, pi + pi / 4, 1.7 * scale);
            Vector2 v4 = fun.Polar(v3, pi + pi / 4, dcx);
            Vector2 v5 = fun.Polar(v4, pi / -2, 1.2 * scale);
            Vector2 v6 = fun.Polar(p42, pi + pi / 4, 1.7 * scale);
            Vector2 v7 = fun.Polar(v6, pi + pi / 4, dcx);
            Vector2 v8 = fun.Polar(v7, pi / -2, 1.2 * scale);
            Vector2 v9 = fun.Polar(p37, pi / -2, fun.CalDistance(p37, p41) / 2.0);
            Vector2 v10 = fun.Polar(v9, pi / -4, 1.7 * scale);
            Vector2 v11 = fun.Polar(v10, pi / -4, dcx);
            Vector2 v12 = fun.Polar(v11, pi / -2, 1.2 * scale);
            Vector2 v13 = fun.Polar(p2, pi + pi / 4, 1.7 * scale);
            Vector2 v14 = fun.Polar(v13, pi + pi / 4, dcx);
            Vector2 v15 = fun.Polar(v14, pi / -2, 1.2 * scale);
            Vector2 v16 = fun.Polar(p0, pi, dcx);
            Vector2 v17 = fun.Polar(v16, pi / 2, dcx * 1.5);
            Vector2 v18 = fun.Polar(v17, pi / 2, dcx / 2.0);
            Vector2 v19 = fun.Polar(v18, pi / 2, dcx / 2.0);
            Vector2 v20 = fun.Polar(p42, pi / 2, dconms + dconms / 10);
            Vector2 v21 = fun.Polar(v20, pi / 4, dconms / 4.0);
            Vector2 v22 = fun.Polar(v21, 0, dconms / 4.0);
            Vector2 v23 = fun.Polar(p42, pi / -2, dconms + dconms / 10);
            Vector2 v24 = fun.Polar(v23, pi / -4, dconms / 4.0);
            Vector2 v25 = fun.Polar(v24, 0, dconms / 4.0);
            Line line12 = new Line(v20, v23);
            Line line13 = new Line(v21, v22);
            Line line14 = new Line(v24, v25);
            Line line15 = new Line(v20, v21);
            Line line16 = new Line(v23, v24);
            line12.Lineweight = Lineweight.W35;//Lineweight指线宽
            line12.Layer = additionalline;//Layer指图层
            line12.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line12.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的

            line13.Lineweight = Lineweight.W35;//Lineweight指线宽
            line13.Layer = additionalline;//Layer指图层
            line13.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line13.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的

            line14.Lineweight = Lineweight.W35;//Lineweight指线宽
            line14.Layer = additionalline;//Layer指图层
            line14.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line14.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的

            line15.Lineweight = Lineweight.W35;//Lineweight指线宽
            line15.Layer = additionalline;//Layer指图层
            line15.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line15.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的

            line16.Lineweight = Lineweight.W35;//Lineweight指线宽
            line16.Layer = additionalline;//Layer指图层
            line16.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line16.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的           
            dxf.AddEntity(new EntityObject[] { line12, line13, line14, line15, line16 });
            fun.dimrot1(dxf, p2, p4, 180, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "APMX", "", "");
            fun.dimrot1(dxf, p1, p2, 90, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.dimrot1(dxf, p3, p4, 90, dcx * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCX", "", "");
            fun.dimrot1(dxf, p0, p42, 0, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR,LTA", "", "");
            fun.dimrot1(dxf, p0, p37, 0, dcx * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LF", "", "");
            fun.dimrot1(dxf, p36, p40, -90, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p41, p39, 180, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p34, p38, 90, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "DN", "", "");
            fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, -fha_, 0.1)), new Line(p0, fun.Polar(p0, 0, 0.1)), dcx * 1.5, 1.2 * scale, 1.6 * scale, 0.9, "FHA", "", "");

            fun.Axis(dxf, fun.Polar(p41, -pi / 3, dcx * 2), 0, -90, "Z", "X", "Y", scale / 2.0, 1.2 * scale, 1);
            fun.Axis(dxf, p0, 0, -90, "", "", "", scale / 2.0, 1.2 * scale, 1);
            fun.Axis(dxf, p42, 0, -90, "", "", "", scale / 2.0, 1.2 * scale, 1);
            fun.Axis(dxf, v9, 0, -90, "", "", "", scale / 2.0, 1.2 * scale, 1);

            fun.Singlelinearrow(dxf, "CCMS", v1, 45, fun.Polar(v1, pi / 4, dcx / 2.0), fun.Polar(v1, pi / 4, dcx), 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "PRFRAD", p32, 135, v2, fun.Polar(v2, pi / 2 + pi / 4, dcx / 2.0), 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "FDP", v19, 90, v18, v17, 1.2 * scale, 1.6 * scale);

            Line line8 = new Line(v3, v4);
            Line line9 = new Line(v6, v7);
            Line line10 = new Line(v10, v11);
            Line line11 = new Line(v13, v14);

            Text txt1 = new Text("CIP", v5, 1.2 * scale, 0);
            Text txt2 = new Text("MCS", v8, 1.2 * scale, 0);
            Text txt3 = new Text("PCS", v12, 1.2 * scale, 0);
            Text txt4 = new Text("CRP", v15, 1.2 * scale, 0);
            Circle circle1 = new Circle(p2, 1.7 * scale);
            dxf.AddEntity(new EntityObject[] { line8, line9, line10, line11, txt1, txt2, txt3, txt4, circle1 });



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void ISYC_303_08(Dictionary<string, Object> data)  //整体凹半圆形轮廓立铣刀
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            //  double sl = Convert.ToDouble(data["oal"]);
            double sl = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);
            /*
            double sl = 68;
            double scale = 1;
            */
            if (sl <= 67)
            {
                scale = 2.2;
            }
            else if (67 < sl && sl <= 75)
            {
                scale = 1.8;
            }
            else if (75 < sl && sl <= 100)
            {
                scale = 1.4;
            }
            else
            {
                scale = 1;
            }
            /*
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double oal = 67 * scale;
            double ls = 35 * scale;
            double apmx = 4.71 * scale;
            double dconms = 14 * scale;
            double dc = 7 * scale;
            double dn = 7 * scale;
            double lpr = 40 * scale;
            double dcx = 14 * scale;
            double fha = 15;
            double fha_ = fha * pi / 180;
           // double prfrad = 7.777778*scale   ;
            double prfrad = 14;
            */
            System.Diagnostics.Debug.WriteLine(1.9 / scale);
            System.Diagnostics.Debug.WriteLine(5588895);

            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dn = Convert.ToDouble(data["dc"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double dcx = Convert.ToDouble(data["dcx"]) * scale;
            double fha = Convert.ToDouble(data["fha"]);
            double fha_ = fha * pi / 180;
            double prfrad = Convert.ToDouble(data["prfrad"]);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_1 = new Vector2(-5, 0);
            Vector2 p0_2 = new Vector2(oal + 5, 0);
            Vector2 p1 = fun.Polar(p0, pi / 2, dc / 2.0);
            Vector2 p2 = fun.mirrorpoint(p1, p0_1, p0_2);
            Vector2 p3 = new Vector2(apmx, dcx / 2.0);
            Vector2 p4 = fun.mirrorpoint(p3, p0_1, p0_2);
            Vector2 p5 = fun.Polar(p3, 0, ((oal - sl - apmx) - 1 * scale - 1 * scale) / 2.0);
            Vector2 p6 = fun.mirrorpoint(p5, p0_1, p0_2);
            Vector2 p7 = fun.Polar(p5, pi / -4, Math.Sqrt(2) * 1 * scale);
            Vector2 p8 = fun.mirrorpoint(p7, p0_1, p0_2);
            Vector2 p9 = fun.Polar(p0, -15 * pi / 180, 100);
            Vector2 p10_1 = new Vector2(38.3817 / 58.881 * (fun.CalDistance(p3, p5)) + apmx, -dcx / 2.0);
            Vector2 p10_2 = fun.Polar(p10_1, pi / 2, 100);
            Vector2 p11 = fun.Polar(p2, fha_ - 20 * pi / 180, 100);
            Vector2 p12 = fun.Inters(p2, p11, p10_1, p10_2);
            Vector2 p13 = fun.Inters(p2, p11, p3, p4);
            Vector2 p14 = fun.Polar(p2, pi / 2, fun.CalDistance(p2, p0) / 2.0);
            Vector2 p15 = fun.Polar(p4, fun.CalAngle(p4, p2), fun.CalDistance(p4, p2) / 2.0);
            Vector2 p16 = fun.Polar(p15, fun.CalAngle(p4, p2) - pi / 2, 100);
            Arc arc2 = fun.DrawArc4(p4, prfrad, p2, 0);
            Arc arc3 = fun.DrawArc4(p13, 14 * scale, p14, 0);
            Vector2 p17 = fun.Inters1(p15, p16, arc2, 1);
            Vector2 p18 = fun.Polar(p13, fun.CalAngle(p13, p14), fun.CalDistance(p13, p14) / 2.0);
            Vector2 p19 = fun.Polar(p18, fun.CalAngle(p13, p14) - pi / 2, 100);
            Vector2 p20 = fun.Inters1(p18, p19, arc3, 1);
            Vector2 p21 = fun.Polar(p0, -6 * pi / 180, 100);
            Vector2 p22 = fun.Inters(p0, p21, p4, p3);
            Vector2 p23 = fun.Polar(p22, -fha_, 100);
            Vector2 p24 = fun.Inters(p22, p23, p10_1, p10_2);
            Vector2 p26 = fun.Polar(p24, pi / 2, dcx / 2.0);
            Vector2 p27 = fun.Polar(p12, pi / 2, dcx / 2.0);
            Vector2 p28 = fun.Polar(p1, pi / -2, fun.CalDistance(p1, p0) / 2.0);
            Vector2 p29 = fun.Polar(p3, pi / -2, fun.CalDistance(p1, p0) / 2.0);
            Vector2 p30 = fun.Polar(p28, pi / -2, fun.CalDistance(p28, p0) / 2.0);
            Vector2 p30_ = fun.Polar(p30, 0.34710403, 100);
            Vector2 p31 = fun.Inters(p30, p30_, p4, p3);
            Arc arc1 = fun.DrawArc4(p1, prfrad, p3, 0);
            Arc arc9 = fun.DrawArc4(p28, prfrad, p29, 0);
            Vector2 p32_ = fun.Polar(p17, pi / 2, 100);
            Vector2 p33_ = fun.Polar(p20, pi / 2 + 5 * pi / 180, 100);
            //Vector2 p33_ = new Vector2(p20.X, 100);
            Vector2 p32 = fun.Inters1(p17, p32_, arc1, 1);
            Vector2 p33 = fun.Inters1(p33_, p20, arc9, 1);

            Vector2 p34 = fun.Polar(p7, 0, ((oal - sl - apmx) - 1 * scale - 1 * scale) / 2.0);
            Vector2 p35 = fun.Polar(p34, pi / 4, Math.Sqrt(2) * 1 * scale);
            Vector2 p36 = fun.Polar(p35, 0, ls - 0.5 * scale);
            Vector2 p37 = fun.Polar(p36, pi / -4, Math.Sqrt(2) * 0.5 * scale);
            Vector2 p38 = fun.mirrorpoint(p34, p0_1, p0_2);
            Vector2 p39 = fun.mirrorpoint(p35, p0_1, p0_2);
            Vector2 p40 = fun.mirrorpoint(p36, p0_1, p0_2);
            Vector2 p41 = fun.mirrorpoint(p37, p0_1, p0_2);
            Vector2 p42 = fun.Polar(p0, 0, lpr);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            fun.PolyFill(dxf, poly1, 0.5, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p35));
            poly2.Vertexes.Add(new LwPolylineVertex(p34));
            poly2.Vertexes.Add(new LwPolylineVertex(p38));
            poly2.Vertexes.Add(new LwPolylineVertex(p39));
            poly2.Vertexes.Add(new LwPolylineVertex(p35));
            poly2.Vertexes.Add(new LwPolylineVertex(p36));
            poly2.Vertexes.Add(new LwPolylineVertex(p37));
            poly2.Vertexes.Add(new LwPolylineVertex(p41));
            poly2.Vertexes.Add(new LwPolylineVertex(p40));
            poly2.Vertexes.Add(new LwPolylineVertex(p36));
            poly2.Vertexes.Add(new LwPolylineVertex(p40));
            poly2.Vertexes.Add(new LwPolylineVertex(p39));
            fun.PolyFill(dxf, poly2, 0.5, contour);
            Line line1 = new Line(p1, p2);
            Line line2 = new Line(p13, p12);
            Line line3 = new Line(p22, p24);
            Line line4 = new Line(p29, p26);
            Line line5 = new Line(p27, p31);
            Line line6 = new Line(p7, p34);
            Line line7 = new Line(p8, p38);
            fun.drawBline(dxf, line1, 0.5, contour);
            /*fun.drawBline(dxf, line2, 0.5, contour);
            fun.drawBline(dxf, line3, 0.5, contour);
            fun.drawBline(dxf, line4, 0.5, contour);
            fun.drawBline(dxf, line5, 0.5, contour);*/
            fun.drawBline(dxf, line6, 0.5, contour);
            fun.drawBline(dxf, line7, 0.5, contour);
            Arc arc4 = fun.DrawArc4(p4, 10 * scale, p13, 0);
            Arc arc5 = fun.DrawArc4(p17, 14 * scale, p20, 0);
            Arc arc6 = fun.DrawArc4(p22, 48 * scale, p0, 0);
            Arc arc7 = fun.DrawArc4(p12, 1.05556 * scale, p24, 0);
            Arc arc8 = fun.DrawArc4(p27, 1.05556 * scale, p26, 0);
            Arc arc10 = fun.DrawArc4(p30, 19.50675846 / 2.0 * scale, p31, 0);
            Arc arc11 = fun.DrawArc4(p29, 5.98423777 / 2.0 * scale, p3, 0);
            Arc arc12 = fun.DrawArc4(p33, 14 * scale, p32, 0);
            Arc arc13 = fun.DrawArc4(p22, 7.3741868 * scale, p31, 0);
            fun.drawBArc(dxf, arc1, 0.8, contour);
            fun.drawBArc(dxf, arc2, 0.8, contour);
            /* fun.drawBArc(dxf, arc3, 0.5, contour);
             fun.drawBArc(dxf, arc4, 0.5, contour);
             fun.drawBArc(dxf, arc5, 0.5, contour);
             fun.drawBArc(dxf, arc6, 0.5, contour);
             fun.drawBArc(dxf, arc7, 0.5, contour);
             fun.drawBArc(dxf, arc8, 0.5, contour);
             fun.drawBArc(dxf, arc9, 0.5, contour);
             fun.drawBArc(dxf, arc10, 0.5, contour);
             fun.drawBArc(dxf, arc11, 0.5, contour);
             fun.drawBArc(dxf, arc12, 0.5, contour);
             fun.drawBArc(dxf, arc13, 0.5, contour);*/
            //标注
            Vector2 v1 = fun.Polar(p35, 0, fun.CalDistance(p35, p36) / 2.0 + 3);
            Vector2 v2 = fun.Polar(p32, pi / 2 + pi / 4, dcx / 2.0);
            Vector2 v3 = fun.Polar(p0, pi + pi / 4, 1.7 * scale);
            Vector2 v4 = fun.Polar(v3, pi + pi / 4, dcx);
            Vector2 v5 = fun.Polar(v4, pi / -2, 1.2 * scale);
            Vector2 v6 = fun.Polar(p42, pi + pi / 4, 1.7 * scale);
            Vector2 v7 = fun.Polar(v6, pi + pi / 4, dcx);
            Vector2 v8 = fun.Polar(v7, pi / -2, 1.2 * scale);
            Vector2 v9 = fun.Polar(p37, pi / -2, fun.CalDistance(p37, p41) / 2.0);
            Vector2 v10 = fun.Polar(v9, pi / -4, 1.7 * scale);
            Vector2 v11 = fun.Polar(v10, pi / -4, dcx);
            Vector2 v12 = fun.Polar(v11, pi / -2, 1.2 * scale);
            Vector2 v13 = fun.Polar(p2, pi + pi / 4, 1.7 * scale);
            Vector2 v14 = fun.Polar(v13, pi + pi / 4, dcx);
            Vector2 v15 = fun.Polar(v14, pi / -2, 1.2 * scale);
            Vector2 v16 = fun.Polar(p0, pi, dcx);
            Vector2 v17 = fun.Polar(v16, pi / 2, dcx * 1.5);
            Vector2 v18 = fun.Polar(v17, pi / 2, dcx / 2.0);
            Vector2 v19 = fun.Polar(v18, pi / 2, dcx / 2.0);

            Vector2 v20 = fun.Polar(p42, pi / 2, dconms + dconms / 10);
            Vector2 v21 = fun.Polar(v20, pi / 4, dconms / 4.0);
            Vector2 v22 = fun.Polar(v21, 0, dconms / 4.0);
            Vector2 v23 = fun.Polar(p42, pi / -2, dconms + dconms / 10);
            Vector2 v24 = fun.Polar(v23, pi / -4, dconms / 4.0);
            Vector2 v25 = fun.Polar(v24, 0, dconms / 4.0);

            fun.dimrot1(dxf, p2, p4, 180, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "APMX", "", "");
            fun.dimrot1(dxf, p2, p8, 180, dcx * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
            fun.dimrot1(dxf, p1, p2, 90, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "DC", "", "");
            fun.dimrot1(dxf, p3, p4, 90, dcx * 2, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCX", "", "");
            fun.dimrot1(dxf, p0, p42, 0, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR", "", "");
            fun.dimrot1(dxf, p0, p37, 0, dcx * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p36, p40, -90, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p41, p39, 180, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "LS", "", "");
            fun.dimrot1(dxf, p34, p38, 90, dcx, 2, 1.2 * scale, 1.6 * scale, 0.9, "DN", "", "");
            Line line9 = new Line(v20, v23);
            Line line10 = new Line(v21, v22);
            Line line11 = new Line(v24, v25);
            Line line12 = new Line(v20, v21);
            Line line13 = new Line(v23, v24);
            line9.Lineweight = Lineweight.W35;//Lineweight指线宽
            line9.Layer = additionalline;//Layer指图层
            line9.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line9.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的

            line10.Lineweight = Lineweight.W35;//Lineweight指线宽
            line10.Layer = additionalline;//Layer指图层
            line10.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line10.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的

            line11.Lineweight = Lineweight.W35;//Lineweight指线宽
            line11.Layer = additionalline;//Layer指图层
            line11.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line11.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的

            line12.Lineweight = Lineweight.W35;//Lineweight指线宽
            line12.Layer = additionalline;//Layer指图层
            line12.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line12.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的

            line13.Lineweight = Lineweight.W35;//Lineweight指线宽
            line13.Layer = additionalline;//Layer指图层
            line13.LinetypeScale = 5 / scale * 1.5;//指线性比例
            line13.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的           
            dxf.AddEntity(new EntityObject[] { line9, line10, line11, line12, line13 });
            /*fun.jdbz2(dxf, new Line(p0, fun.Polar(p0, 0, 0.1)), new Line(p0, fun.Polar(p0, fha_, 0.1)), dcx * 2, 1.2 * scale, 1.6 * scale, 0.9, "FHA", "", "");
            
            fun.Axis(dxf, fun.Polar(p41, -pi / 3, dcx * 2), 0, -90, "Z", "X", "Y", scale / 2.0, 1.2 * scale, 1);
            fun.Axis(dxf, p0, 0, -90, "", "", "", scale / 2.0, 1.2 * scale, 1);
            fun.Axis(dxf, p42, 0, -90, "", "", "", scale / 2.0, 1.2 * scale, 1);
            fun.Axis(dxf, v9, 0, -90, "", "", "", scale / 2.0, 1.2 * scale, 1);

            fun.Singlelinearrow(dxf, "CCMS", v1, 45, fun.Polar(v1, pi / 4, dcx / 2.0), fun.Polar(v1, pi / 4, dcx), 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "PRFRAD", p32, 135, v2, fun.Polar(v2, pi / 2 + pi / 4, dcx / 2.0), 1.2 * scale, 1.6 * scale);
            fun.Singlelinearrow(dxf, "FDP", v19, 90, v18, v17, 1.2 * scale, 1.6 * scale);

            Line line8 = new Line(v3, v4);
            Line line9 = new Line(v6, v7);
            Line line10 = new Line(v10, v11);
            Line line11 = new Line(v13, v14);

            Text txt1 = new Text("CIP", v5, 1.2 * scale, 0);
            Text txt2 = new Text("MCS", v8, 1.2 * scale, 0);
            Text txt3 = new Text("PCS", v12, 1.2 * scale, 0);
            Text txt4 = new Text("CRP", v15, 1.2 * scale, 0);
            Circle circle1 = new Circle(p2, 1.7 * scale);
            dxf.AddEntity(new EntityObject[] { line8, line9, line10, line11, txt1, txt2, txt3, txt4, circle1 });
            */

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void Internalgrooveboringbar(Dictionary<string, Object> data)  //内切槽用可转位刀片镗杆a或b图
        {                                                                            //当q=0时则为a图，否则为b图
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*
            double scale = 1;
            double pi = Math.PI;           
            string path = Convert.ToString(data["path"]);
            double oal = 46.2*scale ;
            double dconms = 10 * scale;
            double lh = 12.8 * scale;
            double ecd = 3.7 * scale;
            double wf = 12.3 * scale;
            double cw = 4.6 * scale;
            double kw = 2.85 * scale;
            double cdx = 6.4 * scale;
            double bc = 0.4 * scale;
            double eca = 45;
            double eca_ = 45 * pi / 180;
            double lpr = oal / 2.0;
            double q = 0;
            */
            double pi = Math.PI;
            double scale = Convert.ToDouble(data["scale"]);
            string path = Convert.ToString(data["path"]);
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double ecd = Convert.ToDouble(data["ecd"]) * scale;
            double wf = Convert.ToDouble(data["wf"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double kw = Convert.ToDouble(data["kw"]) * scale;
            double cdx = Convert.ToDouble(data["cdx"]) * scale;
            double bc = Convert.ToDouble(data["bc"]) * scale;
            double q = Convert.ToDouble(data["q"]);
            double eca = Convert.ToDouble(data["eca"]);
            double eca_ = eca * pi / 180;
            double lpr = oal / 2.0;


            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_ = new Vector2(oal + 5, 0);

            Vector2 p1 = fun.Polar(p0, pi / 2, dconms / 2.0);
            Vector2 p2 = fun.Polar(p1, 0, oal - lh);
            Vector2 p3 = fun.Polar(p2, pi / -2, bc);
            Vector2 p4 = fun.Polar(p3, 0, lh - ecd - bc);
            Vector2 p5 = new Vector2(oal - bc, p4.Y);
            Vector2 p6;
            if (q == 0)
            {

                p6 = new Vector2(p5.X, p0.Y);



            }
            else
            {
                p6 = new Vector2(p5.X, p5.Y);

            }
            Vector2 p7 = fun.Polar(p6, 0, cw / 2.0 - (p5.X - p4.X) / 2.0);
            Vector2 p8 = fun.Polar(p7, pi / -2, kw);
            Vector2 p9 = new Vector2(p6.X, p8.Y);
            Vector2 p10 = fun.mirrorpoint(p5, p0, p0_);
            Vector2 p11 = fun.mirrorpoint(p4, p0, p0_);
            Vector2 p12 = fun.mirrorpoint(p3, p0, p0_);
            Vector2 p13 = fun.mirrorpoint(p2, p0, p0_);
            Vector2 p14 = fun.mirrorpoint(p1, p0, p0_);

            Vector2 p15 = fun.Polar(p7, pi, cw);
            Vector2 p16 = fun.Polar(p6, pi, p5.X - p4.X);
            Vector2 p17 = fun.Polar(p8, pi, cw);
            Vector2 p18 = fun.Polar(p9, pi, p5.X - p4.X);


            Vector2 p19 = fun.Polar(p14, pi / -2, oal);
            Vector2 p20 = fun.Polar(p19, 0, oal - lh);
            Vector2 p28 = fun.Polar(p20, pi / -2, dconms + bc);
            Vector2 p28_ = fun.Polar(p28, 0, 50);
            Vector2 p21 = fun.Polar(p20, 0, lh - ecd - bc);
            Vector2 p22 = fun.Polar(p21, -eca_, ecd / Math.Cos(eca * pi / 180));
            Vector2 p23 = fun.Polar(p22, pi / -2, wf * (1.1 / 1.23));
            Vector2 p24 = new Vector2(oal, p19.Y - dconms / 2.0 - wf);
            Vector2 p25 = fun.Polar(p24, pi, cw);
            Vector2 p25_1 = fun.Polar(p25, 0, (p24.X - p25.X) / 2.0);
            Vector2 p25_2 = fun.Polar(p25_1, pi / 2, 50);
            Vector2 p26 = new Vector2(p25.X + bc, p23.Y);
            Vector2 p26_ = fun.Polar(p26, pi / 2, 50);
            Vector2 p27 = fun.Inters(p28, p28_, p26, p26_);


            Vector2 p29 = fun.Polar(p20, pi / -2, dconms);
            Vector2 p30 = fun.Polar(p19, pi / -2, dconms);
            Vector2 p31 = fun.Polar(p26, 0, 0.06 / 0.46 * cw);
            Vector2 p32 = fun.Polar(p23, pi, 0.06 / 0.46 * cw);
            Vector2 p33 = new Vector2(p26.X + (p31.X - p26.X) / 2.0, p26.Y + (p25.Y - p26.Y) / 2.0);
            Vector2 p34 = new Vector2(p23.X + (p32.X - p23.X) / 2.0, p23.Y + (p24.Y - p23.Y) / 2.0);







            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p7));
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p9));
            poly1.Vertexes.Add(new LwPolylineVertex(p10));
            poly1.Vertexes.Add(new LwPolylineVertex(p11));
            poly1.Vertexes.Add(new LwPolylineVertex(p12));
            poly1.Vertexes.Add(new LwPolylineVertex(p13));
            poly1.Vertexes.Add(new LwPolylineVertex(p14));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            fun.PolyFill(dxf, poly1, 0.5, contour);
            //dxf.AddEntity(poly1);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p4));
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes.Add(new LwPolylineVertex(p6));
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes.Add(new LwPolylineVertex(p17));
            poly2.Vertexes.Add(new LwPolylineVertex(p9));
            poly2.Vertexes.Add(new LwPolylineVertex(p18));
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            poly2.Vertexes.Add(new LwPolylineVertex(p3));
            fun.PolyFill(dxf, poly2, 0.5, contour);
            //dxf.AddEntity(poly2);



            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p19));
            poly3.Vertexes.Add(new LwPolylineVertex(p21));
            poly3.Vertexes.Add(new LwPolylineVertex(p22));
            poly3.Vertexes.Add(new LwPolylineVertex(p23));
            poly3.Vertexes.Add(new LwPolylineVertex(p24));
            poly3.Vertexes.Add(new LwPolylineVertex(p25));
            poly3.Vertexes.Add(new LwPolylineVertex(p26));
            poly3.Vertexes.Add(new LwPolylineVertex(p27));
            poly3.Vertexes.Add(new LwPolylineVertex(p28));
            poly3.Vertexes.Add(new LwPolylineVertex(p29));
            poly3.Vertexes.Add(new LwPolylineVertex(p30));
            poly3.Vertexes.Add(new LwPolylineVertex(p19));
            //dxf.AddEntity(poly3);
            fun.PolyFill(dxf, poly3, 0.5, contour);
            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p23));
            poly4.Vertexes.Add(new LwPolylineVertex(p26));
            poly4.Vertexes.Add(new LwPolylineVertex(p31));
            poly4.Vertexes.Add(new LwPolylineVertex(p33));
            poly4.Vertexes.Add(new LwPolylineVertex(p34));
            poly4.Vertexes.Add(new LwPolylineVertex(p32));
            //dxf.AddEntity(poly4);
            fun.PolyFill(dxf, poly4, 0.5, contour);
            Line line1 = new Line(p29, p20);
            fun.drawBline(dxf, line1, 0.5, contour);
            //dxf.AddEntity(line1);

            if (q == 0)
            {
                //标注
                Vector2 p35 = fun.Polar(p7, pi, lpr);
                Vector2 p36 = fun.Polar(p7, pi, cw / 2.0);
                Vector2 p37 = fun.Polar(p19, pi / -2, dconms / 2.0);
                Vector2 p38 = fun.Polar(p37, 0, oal / 2.0);
                Vector2 p39 = fun.Polar(p37, 0, oal + 5);

                Vector2 p40 = fun.Polar(p7, 60 * pi / 180, 1.7 * 0.025 * scale + 0.3);
                Vector2 p41 = fun.Polar(p40, 60 * pi / 180, dconms / 2.0);
                Vector2 p42 = fun.Polar(p41, pi / 2, 0.3);

                Vector2 p43 = fun.Polar(p36, pi / 2 + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p44 = fun.Polar(p43, pi / 2 + pi / 4, dconms);
                Vector2 p45 = fun.Polar(p44, pi / 2, 0.3);

                Vector2 p46 = fun.Polar(p0, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p47 = fun.Polar(p46, pi + pi / 4, (oal / 2.0 + dconms / 2.0) / Math.Cos(pi / 4) - 0.9);
                Vector2 p48 = fun.Polar(p47, pi / -2, 1.2 + 0.3);
                Vector2 p52 = fun.Polar(p48, pi / -4, 1.2);
                Vector2 p54 = fun.Polar(p37, pi / 4, 1.7 * 0.025 * scale + 0.3);

                Vector2 p49 = fun.Polar(p35, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p50 = fun.Polar(p49, pi + pi / 4, (oal / 2.0 + dconms / 2.0) / Math.Cos(pi / 4) - 0.9);
                Vector2 p51 = fun.Polar(p50, pi / -2, 1.2 + 0.3);
                Vector2 p53 = fun.Polar(p51, pi / -4, 1.2);
                Vector2 p55 = fun.Polar(p38, pi / 2 + pi / 4, 1.7 * 0.025 * scale + 0.3);

                Vector2 p56 = fun.Polar(p38, pi, oal / 4.0);
                Vector2 p57 = fun.Polar(p56, pi / 2, dconms / 2.0);
                Vector2 p58 = fun.Polar(p57, pi / 2 + pi / 4, dconms / 2.0);
                Vector2 p59 = fun.Polar(p58, pi / 2 + pi / 4, dconms / 2.0);

                Vector2 p60 = fun.Polar(p24, pi / -4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p61 = fun.Polar(p60, pi / -4, dconms / 2.0);
                Vector2 p62 = fun.Polar(p61, pi / -4, 0.3);

                Vector2 p63 = fun.Polar(p25_1, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p64 = fun.Polar(p63, pi + pi / 4, dconms);
                Vector2 p65 = fun.Polar(p64, pi / -2, 1.2 + 0.3);

                Vector2 p66 = fun.Polar(p21, 0, dconms * 1.7);
                Vector2 p67 = fun.Polar(p66, pi / -2, dconms + oal + dconms);
                Vector2 p67_ = fun.Polar(p67, pi, 1.2 * scale * 3);
                Vector2 p68 = fun.Polar(p67, pi / 2, dconms / 2.0);
                Vector2 p69 = fun.Polar(p68, pi / 2, dconms / 2.0);

                Vector2 p70 = fun.Polar(p35, pi / 2, oal / 2);

                fun.Axis(dxf, p0, 180, 90, "Z", "Y", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p35, 180, 90, "Z", "Y", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p36, 90, 0, "Z", "X", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p37, 180, -90, "Z", "X", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p38, 180, -90, "Z", "X", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p25_1, 0, 90, "X", "Y", "", 0.25 * scale, 1.2 * scale, 0);

                fun.dimrot1(dxf, p35, p7, 0, oal / 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR,LTA", "", "");
                fun.dimrot1(dxf, p7, fun.Polar(p7, pi / -2, 0.001), -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "HTA,HF", "", "");
                fun.dimrot1(dxf, p19, p30, 90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
                fun.dimrot1(dxf, p20, p24, 0, oal / 4.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
                fun.dimrot1(dxf, p21, p22, -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "ECD", "", "");
                fun.dimrot1(dxf, p24, p39, -90, dconms * 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF.WTA", "", "");
                fun.dimrot1(dxf, p25, p24, 180, oal / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "CW", "", "");
                fun.dimrot1(dxf, p30, p24, 180, oal, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LF", "", "");
                fun.dimrot1(dxf, p27, p25, 90, lh / 3.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "CDX", "", "");

                fun.jdbz2(dxf, new Line(p21, p22), new Line(p21, fun.Polar(p21, 0, 0.1)), dconms * 1.7, 1.2 * scale, 1.6 * scale, 0.9, "ECA", "", "");
                fun.jdbz2(dxf, new Line(p24, p25), new Line(p24, fun.Polar(p24, pi / -2, 0.1)), oal / 1.5, 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");

                fun.Singlelinearrow(dxf, "CCMS", p57, 135, p58, p59, 1.2 * scale, 1.6 * scale);
                fun.Singlelinearrow(dxf, "", p67, -90, p68, p69, 1.2 * scale, 1.6 * scale);

                Line line2 = new Line(p0, p0_);
                line2.Lineweight = Lineweight.W25;//Lineweight指线宽
                line2.Layer = center;//Layer指图层
                line2.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line2);

                Line line3 = new Line(p37, p39);
                line3.Lineweight = Lineweight.W25;//Lineweight指线宽
                line3.Layer = center;//Layer指图层
                line3.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line3);

                Line line4 = new Line(p40, p41);
                Text txt4 = new Text("CRP", p42, 1.2 * scale, 0);
                Line line5 = new Line(p43, p44);
                Text txt5 = new Text("CSW", p45, 1.2 * scale, 0);
                Line line6 = new Line(p46, p47);
                Text txt6 = new Text("PCS", p48, 1.2 * scale, 0);
                Line line7 = new Line(p49, p50);
                Text txt7 = new Text("MCS", p51, 1.2 * scale, 0);
                Line line8 = new Line(p52, p54);
                Line line9 = new Line(p53, p55);
                Line line10 = new Line(p60, p61);
                Text txt10 = new Text("CRP", p62, 1.2 * scale, 0);
                Line line11 = new Line(p63, p64);
                Text txt11 = new Text("CSW", p65, 1.2 * scale, 0);
                Text txt12 = new Text("ISYC=309-05a", p70, 1.2 * scale, 0);
                Text txt13 = new Text("FDP", p67_, 1.2 * scale, 0);


                Circle circlex = new Circle(p7, 1.7 * 0.25 * scale);
                Circle circle1 = new Circle(p24, 1.7 * 0.25 * scale);
                dxf.AddEntity(new EntityObject[] { circlex ,circle1 ,line4,line5,line6 ,line7,line8 ,line9 ,line10,line11 ,txt4 ,txt5 ,
                txt6 ,txt7, txt10,txt11,txt12,txt13   });
            }
            else
            {
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.8 * scale;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                dimensionStyle.TextHeight = 1.2 * scale;
                double offset = 0.1 * scale;
                //标注
                Vector2 p35 = fun.Polar(fun.Polar(p7, pi / 2, bc), pi, lpr);
                Vector2 p36 = fun.Polar(p7, pi, cw / 2.0);
                Vector2 p37 = fun.Polar(p19, pi / -2, dconms / 2.0);
                Vector2 p38 = fun.Polar(p37, 0, oal / 2.0);
                Vector2 p39 = fun.Polar(p37, 0, oal + 5);

                Vector2 p40 = fun.Polar(p7, 60 * pi / 180, 1.7 * 0.025 * scale + 0.3);
                Vector2 p41 = fun.Polar(p40, 60 * pi / 180, dconms / 2.0);
                Vector2 p42 = fun.Polar(p41, pi / 2, 0.3);

                Vector2 p43 = fun.Polar(p36, pi / 2 + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p44 = fun.Polar(p43, pi / 2 + pi / 4, dconms);
                Vector2 p45 = fun.Polar(p44, pi / 2, 0.3);

                Vector2 p46 = fun.Polar(p0, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p47 = fun.Polar(p46, pi + pi / 4, (oal / 2.0 + dconms / 2.0) / Math.Cos(pi / 4) - 0.9);
                Vector2 p48 = fun.Polar(p47, pi / -2, 1.2 + 0.3);
                Vector2 p52 = fun.Polar(p48, pi / -4, 1.2);
                Vector2 p54 = fun.Polar(p37, pi / 4, 1.7 * 0.025 * scale + 0.3);

                Vector2 p49 = fun.Polar(p35, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p50 = fun.Polar(p49, pi + pi / 4, (oal / 2.0 + dconms / 2.0) / Math.Cos(pi / 4) - 0.9);
                Vector2 p51 = fun.Polar(p50, pi / -2, 1.2 + 0.3);
                Vector2 p53 = fun.Polar(p51, pi / -4, 1.2);
                Vector2 p55 = fun.Polar(p38, pi / 2 + pi / 4, 1.7 * 0.025 * scale + 0.3);

                Vector2 p56 = fun.Polar(p38, pi, oal / 4.0);
                Vector2 p57 = fun.Polar(p56, pi / 2, dconms / 2.0);
                Vector2 p58 = fun.Polar(p57, pi / 2 + pi / 4, dconms / 2.0);
                Vector2 p59 = fun.Polar(p58, pi / 2 + pi / 4, dconms / 2.0);

                Vector2 p60 = fun.Polar(p24, pi / -4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p61 = fun.Polar(p60, pi / -4, dconms / 2.0);
                Vector2 p62 = fun.Polar(p61, pi / -4, 0.3);

                Vector2 p63 = fun.Polar(p25_1, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p64 = fun.Polar(p63, pi + pi / 4, dconms);
                Vector2 p65 = fun.Polar(p64, pi / -2, 1.2 + 0.3);

                Vector2 p66 = fun.Polar(p21, 0, dconms * 1.7);
                Vector2 p67 = fun.Polar(p66, pi / -2, dconms + oal + dconms);
                Vector2 p68 = fun.Polar(p67, pi / 2, dconms / 2.0);
                Vector2 p68_ = fun.Polar(p68, pi, 1.2 * scale * 3);
                Vector2 p69 = fun.Polar(p68, pi / 2, dconms / 2.0);

                Vector2 p70 = fun.Polar(p35, pi / 2, oal / 2);
                Vector2 p71 = fun.Polar(p57, pi, bc);
                Vector2 p72 = fun.Polar(p71, pi / -2, dconms / 2.0);
                Vector2 p73 = fun.Polar(p72, pi / -2, dconms / 2.0);

                fun.Axis(dxf, p14, 180, 90, "Z", "Y", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p35, 180, 90, "Z", "Y", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p36, 90, 0, "Z", "X", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p19, 180, -90, "Z", "X", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p38, 180, -90, "Z", "X", "", 0.25 * scale, 1.2 * scale, 0);
                fun.Axis(dxf, p25_1, 0, 90, "X", "Y", "", 0.25 * scale, 1.2 * scale, 0);

                fun.dimrot1(dxf, p35, p7, 0, oal / 3, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR,LTA", "", "");
                fun.dimrot1(dxf, p7, fun.Polar(p7, pi / -2, 0.001), -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "HTA", "", "");
                fun.dimrot1(dxf, p19, p30, 90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "B", "", "");
                fun.dimrot1(dxf, p20, p24, 0, oal / 4.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
                fun.dimrot1(dxf, p21, p22, -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "ECD", "", "");
                fun.dimrot1(dxf, p24, p21, -90, dconms * 3.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF", "", "");
                fun.dimrot1(dxf, p25, p24, 180, oal / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "CW", "", "");
                fun.dimrot1(dxf, p30, p24, 180, oal, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LF", "", "");
                fun.dimrot1(dxf, p27, p25, 90, lh / 3.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "CDX", "", "");
                fun.dimrot1(dxf, p10, p5, -90, dconms / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "HF", "", "");
                fun.dimrot1(dxf, p1, p14, 90, dconms / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "H", "", "");
                fun.dimrot1(dxf, p24, p39, -90, dconms - ecd - bc * 2.0 - 0.25, 2, 1.2 * scale, 1.6 * scale, 0.9, "WTA", "", "");
                //    fun.dimrot1(dxf, p71, p72, 90, 1, 2, 1.2 * scale, 1.6 * scale, 0.9, "Ⅱ", "", "");
                //    fun.dimrot1(dxf, p72, p73, 90, 1, 2, 1.2 * scale, 1.6 * scale, 0.9, "Ⅱ", "", "");

                LinearDimension linedim1 = new LinearDimension(new Line(p71, p72), offset, 90, dimensionStyle);
                linedim1.UserText = String.Format("Ⅱ", 1);
                dxf.AddEntity(linedim1);
                LinearDimension linedim2 = new LinearDimension(new Line(p72, p73), offset, 90, dimensionStyle);
                linedim2.UserText = String.Format("Ⅱ", 1);
                dxf.AddEntity(linedim2);




                fun.jdbz2(dxf, new Line(p21, p22), new Line(p21, fun.Polar(p21, 0, 0.1)), dconms * 2.7, 1.2 * scale, 1.6 * scale, 0.9, "ECA", "", "");
                fun.jdbz2(dxf, new Line(p24, p25), new Line(p24, fun.Polar(p24, pi / -2, 0.1)), oal / 1.5, 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");

                fun.Singlelinearrow(dxf, "CCMS", p57, 135, p58, p59, 1.2 * scale, 1.6 * scale);
                fun.Singlelinearrow(dxf, "", p67, -90, p68, p69, 1.2 * scale, 1.6 * scale);



                Line line4 = new Line(p40, p41);
                Text txt4 = new Text("CRP", p42, 1.2 * scale, 0);
                Line line5 = new Line(p43, p44);
                Text txt5 = new Text("CSW", p45, 1.2 * scale, 0);
                Line line6 = new Line(p46, p47);
                Text txt6 = new Text("PCS", p48, 1.2 * scale, 0);
                Line line7 = new Line(p49, p50);
                Text txt7 = new Text("MCS", p51, 1.2 * scale, 0);
                Line line8 = new Line(p52, p54);
                Line line9 = new Line(p53, p55);
                Line line10 = new Line(p60, p61);
                Text txt10 = new Text("CRP", p62, 1.2 * scale, 0);
                Line line11 = new Line(p63, p64);
                Text txt11 = new Text("CSW", p65, 1.2 * scale, 0);
                Text txt12 = new Text("ISYC=309-05b", p70, 1.2 * scale, 0);
                Text txt13 = new Text("FDP", p68_, 1.2 * scale, 0);


                Circle circlex = new Circle(p7, 1.7 * 0.25 * scale);
                Circle circle1 = new Circle(p24, 1.7 * 0.25 * scale);
                dxf.AddEntity(new EntityObject[] { circlex ,circle1 ,line4,line5,line6 ,line7,line8 ,line9 ,line10,line11 ,txt4 ,txt5 ,
                txt6 ,txt7, txt10,txt11,txt12,txt13   });
            }


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

        public static void Bladehandlebackboringbar(Dictionary<string, Object> data)  //可转位刀片柄连接背镗杆
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*
            double scale = 1;
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double oal = 46.2 * scale;
            double dconms = 10 * scale;
            double lh = 12.8 * scale;
            double r = 4.62*scale ;
            double ecd = 3.7 * scale;
            double wf = 12.3 * scale;
            double cw = 4.6 * scale;
            double kw = 2.85 * scale;
            double cdx = 6.4 * scale;
            double bc = 0.4 * scale;
            double eca = 45;
            double eca_ = 45 * pi / 180;
            double lpr = oal / 2.0;
            double q = 0;
            */
            double pi = Math.PI;
            double scale = Convert.ToDouble(data["scale"]);
            string path = Convert.ToString(data["path"]);
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double ecd = Convert.ToDouble(data["ecd"]) * scale;
            double wf = Convert.ToDouble(data["wf"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double kw = Convert.ToDouble(data["kw"]) * scale;
            double cdx = Convert.ToDouble(data["cdx"]) * scale;
            double bc = Convert.ToDouble(data["bc"]) * scale;
            double q = Convert.ToDouble(data["q"]);
            double eca = Convert.ToDouble(data["eca"]);
            double eca_ = eca * pi / 180;
            double lpr = oal / 2.0;


            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_ = new Vector2(oal + 5, 0);

            Vector2 p1 = fun.Polar(p0, pi / 2, dconms / 2.0);
            Vector2 p2 = fun.Polar(p1, 0, oal - lh);
            Vector2 p3 = fun.Polar(p2, pi / -2, bc);
            Vector2 p4 = fun.Polar(p3, 0, bc);


            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

        public static void ISYC_309_05ab(Dictionary<string, Object> data)  //  ISYC_309_05ab       内切槽用可转位刀片镗杆a或b图
        {                                                                            //当q=0时则为a图，否则为b图
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);

            /*
            double scale = 1;
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);
            double oal = 46.2 * scale;
            double dconms = 10 * scale;
            double lh = 12.8 * scale;
            double ecd = 3.7 * scale;
            double wf = 12.3 * scale;
            double cw = 4.6 * scale;
            double kw = 2.85 * scale;
            double cdx = 6.4 * scale;
            double bc = 0.4 * scale;
            double eca = 45;
            double eca_ = 45 * pi / 180;
            double lpr = oal / 2.0;
            double q = 0;
            */
            double pi = Math.PI;
            double scale = Convert.ToDouble(data["scale"]);
            string path = Convert.ToString(data["path"]);
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double ecd = Convert.ToDouble(data["ecd"]) * scale;
            double wf = Convert.ToDouble(data["wf"]) * scale;
            double cw = Convert.ToDouble(data["cw"]) * scale;
            double kw = Convert.ToDouble(data["kw"]) * scale;
            double cdx = Convert.ToDouble(data["cdx"]) * scale;
            double bc = Convert.ToDouble(data["bc"]) * scale;
            double q = Convert.ToDouble(data["q"]);
            double eca = Convert.ToDouble(data["eca"]);
            double eca_ = eca * pi / 180;
            double lpr = oal / 2.0;


            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0_ = new Vector2(oal + 5, 0);

            Vector2 p1 = fun.Polar(p0, pi / 2, dconms / 2.0);
            Vector2 p2 = fun.Polar(p1, 0, oal - lh);
            Vector2 p3 = fun.Polar(p2, pi / -2, bc);
            Vector2 p4 = fun.Polar(p3, 0, lh - ecd - bc);
            Vector2 p5 = new Vector2(oal - bc, p4.Y);
            Vector2 p6;
            if (q == 0)
            {

                p6 = new Vector2(p5.X, p0.Y);



            }
            else
            {
                p6 = new Vector2(p5.X, p5.Y);

            }
            Vector2 p7 = fun.Polar(p6, 0, cw / 2.0 - (p5.X - p4.X) / 2.0);
            Vector2 p8 = fun.Polar(p7, pi / -2, kw);
            Vector2 p9 = new Vector2(p6.X, p8.Y);
            Vector2 p10 = fun.mirrorpoint(p5, p0, p0_);
            Vector2 p11 = fun.mirrorpoint(p4, p0, p0_);
            Vector2 p12 = fun.mirrorpoint(p3, p0, p0_);
            Vector2 p13 = fun.mirrorpoint(p2, p0, p0_);
            Vector2 p14 = fun.mirrorpoint(p1, p0, p0_);

            Vector2 p15 = fun.Polar(p7, pi, cw);
            Vector2 p16 = fun.Polar(p6, pi, p5.X - p4.X);
            Vector2 p17 = fun.Polar(p8, pi, cw);
            Vector2 p18 = fun.Polar(p9, pi, p5.X - p4.X);


            Vector2 p19 = fun.Polar(p14, pi / -2, oal);
            Vector2 p20 = fun.Polar(p19, 0, oal - lh);
            Vector2 p28 = fun.Polar(p20, pi / -2, dconms + bc);
            Vector2 p28_ = fun.Polar(p28, 0, 50);
            Vector2 p21 = fun.Polar(p20, 0, lh - ecd - bc);
            Vector2 p22 = fun.Polar(p21, -eca_, ecd / Math.Cos(eca * pi / 180));
            Vector2 p23 = fun.Polar(p22, pi / -2, wf * (1.1 / 1.23));
            Vector2 p24 = new Vector2(oal, p19.Y - dconms / 2.0 - wf);
            Vector2 p25 = fun.Polar(p24, pi, cw);
            Vector2 p25_1 = fun.Polar(p25, 0, (p24.X - p25.X) / 2.0);
            Vector2 p25_2 = fun.Polar(p25_1, pi / 2, 50);
            Vector2 p26 = new Vector2(p25.X + bc, p23.Y);
            Vector2 p26_ = fun.Polar(p26, pi / 2, 50);
            Vector2 p27 = fun.Inters(p28, p28_, p26, p26_);


            Vector2 p29 = fun.Polar(p20, pi / -2, dconms);
            Vector2 p30 = fun.Polar(p19, pi / -2, dconms);
            Vector2 p31 = fun.Polar(p26, 0, 0.06 / 0.46 * cw);
            Vector2 p32 = fun.Polar(p23, pi, 0.06 / 0.46 * cw);
            Vector2 p33 = new Vector2(p26.X + (p31.X - p26.X) / 2.0, p26.Y + (p25.Y - p26.Y) / 2.0);
            Vector2 p34 = new Vector2(p23.X + (p32.X - p23.X) / 2.0, p23.Y + (p24.Y - p23.Y) / 2.0);











            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p19));
            poly3.Vertexes.Add(new LwPolylineVertex(p21));
            poly3.Vertexes.Add(new LwPolylineVertex(p22));
            poly3.Vertexes.Add(new LwPolylineVertex(p23));
            poly3.Vertexes.Add(new LwPolylineVertex(p24));
            poly3.Vertexes.Add(new LwPolylineVertex(p25));
            poly3.Vertexes.Add(new LwPolylineVertex(p26));
            poly3.Vertexes.Add(new LwPolylineVertex(p27));
            poly3.Vertexes.Add(new LwPolylineVertex(p28));
            poly3.Vertexes.Add(new LwPolylineVertex(p29));
            poly3.Vertexes.Add(new LwPolylineVertex(p30));
            poly3.Vertexes.Add(new LwPolylineVertex(p19));
            //dxf.AddEntity(poly3);
            fun.PolyFill(dxf, poly3, 0.5, contour);
            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p23));
            poly4.Vertexes.Add(new LwPolylineVertex(p26));
            poly4.Vertexes.Add(new LwPolylineVertex(p31));
            poly4.Vertexes.Add(new LwPolylineVertex(p33));
            poly4.Vertexes.Add(new LwPolylineVertex(p34));
            poly4.Vertexes.Add(new LwPolylineVertex(p32));
            //dxf.AddEntity(poly4);
            fun.PolyFill(dxf, poly4, 0.5, contour);
            Line line1 = new Line(p29, p20);
            fun.drawBline(dxf, line1, 0.5, contour);
            //dxf.AddEntity(line1);

            if (q == 0)
            {
                //标注
                Vector2 p35 = fun.Polar(p7, pi, lpr);
                Vector2 p36 = fun.Polar(p7, pi, cw / 2.0);
                Vector2 p37 = fun.Polar(p19, pi / -2, dconms / 2.0);
                Vector2 p38 = fun.Polar(p37, 0, oal / 2.0);
                Vector2 p39 = fun.Polar(p37, 0, oal + 5);

                Vector2 p40 = fun.Polar(p7, 60 * pi / 180, 1.7 * 0.025 * scale + 0.3);
                Vector2 p41 = fun.Polar(p40, 60 * pi / 180, dconms / 2.0);
                Vector2 p42 = fun.Polar(p41, pi / 2, 0.3);

                Vector2 p43 = fun.Polar(p36, pi / 2 + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p44 = fun.Polar(p43, pi / 2 + pi / 4, dconms);
                Vector2 p45 = fun.Polar(p44, pi / 2, 0.3);

                Vector2 p46 = fun.Polar(p0, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p47 = fun.Polar(p46, pi + pi / 4, (oal / 2.0 + dconms / 2.0) / Math.Cos(pi / 4) - 0.9);
                Vector2 p48 = fun.Polar(p47, pi / -2, 1.2 + 0.3);
                Vector2 p52 = fun.Polar(p48, pi / -4, 1.2);
                Vector2 p54 = fun.Polar(p37, pi / 4, 1.7 * 0.025 * scale + 0.3);

                Vector2 p49 = fun.Polar(p35, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p50 = fun.Polar(p49, pi + pi / 4, (oal / 2.0 + dconms / 2.0) / Math.Cos(pi / 4) - 0.9);
                Vector2 p51 = fun.Polar(p50, pi / -2, 1.2 + 0.3);
                Vector2 p53 = fun.Polar(p51, pi / -4, 1.2);
                Vector2 p55 = fun.Polar(p38, pi / 2 + pi / 4, 1.7 * 0.025 * scale + 0.3);

                Vector2 p56 = fun.Polar(p38, pi, oal / 4.0);
                Vector2 p57 = fun.Polar(p56, pi / 2, dconms / 2.0);
                Vector2 p58 = fun.Polar(p57, pi / 2 + pi / 4, dconms / 2.0);
                Vector2 p59 = fun.Polar(p58, pi / 2 + pi / 4, dconms / 2.0);

                Vector2 p60 = fun.Polar(p24, pi / -4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p61 = fun.Polar(p60, pi / -4, dconms / 2.0);
                Vector2 p62 = fun.Polar(p61, pi / -4, 0.3);

                Vector2 p63 = fun.Polar(p25_1, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p64 = fun.Polar(p63, pi + pi / 4, dconms);
                Vector2 p65 = fun.Polar(p64, pi / -2, 1.2 + 0.3);

                Vector2 p66 = fun.Polar(p21, 0, dconms * 1.7);
                Vector2 p67 = fun.Polar(p66, pi / -2, dconms + oal + dconms);
                Vector2 p67_ = fun.Polar(p67, pi, 1.2 * scale * 3);
                Vector2 p68 = fun.Polar(p67, pi / 2, dconms / 2.0);
                Vector2 p69 = fun.Polar(p68, pi / 2, dconms / 2.0);

                Vector2 p70 = fun.Polar(p35, pi / 2, oal / 2);





                fun.dimrot1(dxf, p19, p30, 90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
                fun.dimrot1(dxf, p20, p24, 0, oal / 4.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
                fun.dimrot1(dxf, p21, p22, -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "ECD", "", "");
                fun.dimrot1(dxf, p24, p39, -90, dconms * 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF.WTA", "", "");
                fun.dimrot1(dxf, p25, p24, 180, oal / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "CW", "", "");
                fun.dimrot1(dxf, p30, p24, 180, oal, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LF", "", "");
                fun.dimrot1(dxf, p27, p25, 90, lh / 3.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "CDX", "", "");
                fun.dimrot1(dxf, p30, p25_1, 180, oal / 4.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LF", "", "");

                fun.jdbz2(dxf, new Line(p21, p22), new Line(p21, fun.Polar(p21, 0, 0.1)), dconms * 1.7, 1.2 * scale, 1.6 * scale, 0.9, "ECA", "", "");
                fun.jdbz2(dxf, new Line(p24, p25), new Line(p24, fun.Polar(p24, pi / -2, 0.1)), oal / 1.5, 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");






                Line line3 = new Line(p37, p39);
                line3.Lineweight = Lineweight.W25;//Lineweight指线宽
                line3.Layer = center;//Layer指图层
                line3.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line3);

            }
            else
            {
                //标注
                Vector2 p35 = fun.Polar(p7, pi, lpr);
                Vector2 p36 = fun.Polar(p7, pi, cw / 2.0);
                Vector2 p37 = fun.Polar(p19, pi / -2, dconms / 2.0);
                Vector2 p38 = fun.Polar(p37, 0, oal / 2.0);
                Vector2 p39 = fun.Polar(p37, 0, oal + 5);

                Vector2 p40 = fun.Polar(p7, 60 * pi / 180, 1.7 * 0.025 * scale + 0.3);
                Vector2 p41 = fun.Polar(p40, 60 * pi / 180, dconms / 2.0);
                Vector2 p42 = fun.Polar(p41, pi / 2, 0.3);

                Vector2 p43 = fun.Polar(p36, pi / 2 + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p44 = fun.Polar(p43, pi / 2 + pi / 4, dconms);
                Vector2 p45 = fun.Polar(p44, pi / 2, 0.3);

                Vector2 p46 = fun.Polar(p0, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p47 = fun.Polar(p46, pi + pi / 4, (oal / 2.0 + dconms / 2.0) / Math.Cos(pi / 4) - 0.9);
                Vector2 p48 = fun.Polar(p47, pi / -2, 1.2 + 0.3);
                Vector2 p52 = fun.Polar(p48, pi / -4, 1.2);
                Vector2 p54 = fun.Polar(p37, pi / 4, 1.7 * 0.025 * scale + 0.3);

                Vector2 p49 = fun.Polar(p35, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p50 = fun.Polar(p49, pi + pi / 4, (oal / 2.0 + dconms / 2.0) / Math.Cos(pi / 4) - 0.9);
                Vector2 p51 = fun.Polar(p50, pi / -2, 1.2 + 0.3);
                Vector2 p53 = fun.Polar(p51, pi / -4, 1.2);
                Vector2 p55 = fun.Polar(p38, pi / 2 + pi / 4, 1.7 * 0.025 * scale + 0.3);

                Vector2 p56 = fun.Polar(p38, pi, oal / 4.0);
                Vector2 p57 = fun.Polar(p56, pi / 2, dconms / 2.0);
                Vector2 p58 = fun.Polar(p57, pi / 2 + pi / 4, dconms / 2.0);
                Vector2 p59 = fun.Polar(p58, pi / 2 + pi / 4, dconms / 2.0);

                Vector2 p60 = fun.Polar(p24, pi / -4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p61 = fun.Polar(p60, pi / -4, dconms / 2.0);
                Vector2 p62 = fun.Polar(p61, pi / -4, 0.3);

                Vector2 p63 = fun.Polar(p25_1, pi + pi / 4, 1.7 * 0.025 * scale + 0.3);
                Vector2 p64 = fun.Polar(p63, pi + pi / 4, dconms);
                Vector2 p65 = fun.Polar(p64, pi / -2, 1.2 + 0.3);

                Vector2 p66 = fun.Polar(p21, 0, dconms * 1.7);
                Vector2 p67 = fun.Polar(p66, pi / -2, dconms + oal + dconms);
                Vector2 p67_ = fun.Polar(p67, pi, 1.2 * scale * 3);
                Vector2 p68 = fun.Polar(p67, pi / 2, dconms / 2.0);
                Vector2 p69 = fun.Polar(p68, pi / 2, dconms / 2.0);

                Vector2 p70 = fun.Polar(p35, pi / 2, oal / 2);





                fun.dimrot1(dxf, p19, p30, 90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
                fun.dimrot1(dxf, p20, p24, 0, oal / 4.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
                fun.dimrot1(dxf, p21, p22, -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "ECD", "", "");
                fun.dimrot1(dxf, p24, p39, -90, dconms * 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF.WTA", "", "");
                fun.dimrot1(dxf, p25, p24, 180, oal / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "CW", "", "");
                fun.dimrot1(dxf, p30, p24, 180, oal, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL,LF", "", "");
                fun.dimrot1(dxf, p27, p25, 90, lh / 3.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "CDX", "", "");
                fun.dimrot1(dxf, p30, p25_1, 180, oal / 4.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LF", "", "");

                fun.jdbz2(dxf, new Line(p21, p22), new Line(p21, fun.Polar(p21, 0, 0.1)), dconms * 1.7, 1.2 * scale, 1.6 * scale, 0.9, "ECA", "", "");
                fun.jdbz2(dxf, new Line(p24, p25), new Line(p24, fun.Polar(p24, pi / -2, 0.1)), oal / 1.5, 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");






                Line line3 = new Line(p37, p39);
                line3.Lineweight = Lineweight.W25;//Lineweight指线宽
                line3.Layer = center;//Layer指图层
                line3.Linetype = Linetype.DashDot;//Linetype指是点划线还是虚线什么的
                dxf.AddEntity(line3);


            }

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }
    }
}
